Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1435)

Issue 22546004: Remove .tmpl extension from Jinja templates in core

Created:
7 years, 4 months ago by Nils Barth (inactive)
Modified:
7 years, 4 months ago
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch, do-not-use, alancutter (OOO until 2018), haraken
Visibility:
Public.

Description

Remove .tmpl extension from Jinja templates in core Jinja templates generally use the extension of the file they generate: "A template is simply a text file. It can generate any text-based format (HTML, XML, CSV, LaTeX, etc.). It doesn’t have a specific extension, .html or .xml are just fine." http://jinja.pocoo.org/docs/templates/ However, we needed to add an extension (here .tmpl) to prevent check-webkit-style in presubmit scripts from complaining about style, since it can't understand Jinja syntax. I fixed this in this CL: Issue 22514002: Disable check-webkit-style for Jinja templates https://codereview.chromium.org/22514002/ ...and thus there is no more need for these extensions. I've left the .tmpl for the macros.tmpl file, as that not a specific output (it's just Jinja macros). This issue arose in the bindings, so I fixed it there, and for consistency I'm proposing to change it in core as well; see thread: https://codereview.chromium.org/21006006/#msg8 https://codereview.chromium.org/21006006/#msg11 https://codereview.chromium.org/21006006/#msg13 https://codereview.chromium.org/21006006/#msg14 https://codereview.chromium.org/21006006/#msg15

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -1116 lines) Patch
M Source/core/core_derived_sources.gyp View 4 chunks +9 lines, -9 lines 0 comments Download
M Source/core/scripts/make_internal_runtime_flags.py View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/scripts/make_runtime_features.py View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/scripts/make_style_builder.py View 2 chunks +4 lines, -4 lines 0 comments Download
M Source/core/scripts/make_style_shorthands.py View 1 chunk +2 lines, -2 lines 0 comments Download
A + Source/core/scripts/templates/InternalRuntimeFlags.h View 0 chunks +-1 lines, --1 lines 0 comments Download
A + Source/core/scripts/templates/InternalRuntimeFlags.idl View 0 chunks +-1 lines, --1 lines 0 comments Download
D Source/core/scripts/templates/InternalRuntimeFlags.h.tmpl View 1 chunk +0 lines, -40 lines 0 comments Download
D Source/core/scripts/templates/InternalRuntimeFlags.idl.tmpl View 1 chunk +0 lines, -15 lines 0 comments Download
A + Source/core/scripts/templates/RuntimeEnabledFeatures.h View 0 chunks +-1 lines, --1 lines 0 comments Download
A + Source/core/scripts/templates/RuntimeEnabledFeatures.cpp View 0 chunks +-1 lines, --1 lines 0 comments Download
D Source/core/scripts/templates/RuntimeEnabledFeatures.cpp.tmpl View 1 chunk +0 lines, -25 lines 0 comments Download
D Source/core/scripts/templates/RuntimeEnabledFeatures.h.tmpl View 1 chunk +0 lines, -48 lines 0 comments Download
A + Source/core/scripts/templates/StyleBuilder.cpp View 0 chunks +-1 lines, --1 lines 0 comments Download
D Source/core/scripts/templates/StyleBuilder.cpp.tmpl View 1 chunk +0 lines, -136 lines 0 comments Download
A + Source/core/scripts/templates/StyleBuilderFunctions.h View 0 chunks +-1 lines, --1 lines 0 comments Download
A + Source/core/scripts/templates/StyleBuilderFunctions.cpp View 1 chunk +1 line, -1 line 0 comments Download
D Source/core/scripts/templates/StyleBuilderFunctions.cpp.tmpl View 1 chunk +0 lines, -652 lines 0 comments Download
D Source/core/scripts/templates/StyleBuilderFunctions.h.tmpl View 1 chunk +0 lines, -22 lines 0 comments Download
A + Source/core/scripts/templates/StylePropertyShorthand.h View 0 chunks +-1 lines, --1 lines 0 comments Download
A + Source/core/scripts/templates/StylePropertyShorthand.cpp View 0 chunks +-1 lines, --1 lines 0 comments Download
D Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl View 1 chunk +0 lines, -79 lines 0 comments Download
D Source/core/scripts/templates/StylePropertyShorthand.h.tmpl View 1 chunk +0 lines, -87 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Nils Barth (inactive)
Hi Timothy (+ Eric & Dimitri), Just a lil' renaming patch: I fixed the presubmit ...
7 years, 4 months ago (2013-08-08 02:02:26 UTC) #1
haraken
On 2013/08/08 02:02:26, Nils Barth wrote: > Hi Timothy (+ Eric & Dimitri), > > ...
7 years, 4 months ago (2013-08-08 02:20:21 UTC) #2
Nils Barth (inactive)
On 2013/08/08 02:20:21, haraken wrote: > This change looks good to me, but other folks ...
7 years, 4 months ago (2013-08-08 02:24:06 UTC) #3
Timothy Loh
On 2013/08/08 02:24:06, Nils Barth wrote: > > Another reason why we suffix the template ...
7 years, 4 months ago (2013-08-08 02:47:34 UTC) #4
Nils Barth (inactive)
On 2013/08/08 02:47:34, Timothy Loh wrote: > This seems fine to me, consistency is good. ...
7 years, 4 months ago (2013-08-08 05:11:22 UTC) #5
esprehn
This is going to do sad things to syntax highlighting in people's editors. Most do ...
7 years, 4 months ago (2013-08-08 16:14:05 UTC) #6
dglazkov
I am okay with this. Eric?
7 years, 4 months ago (2013-08-08 16:14:13 UTC) #7
eseidel
I don't really care one way or the other. Like Elliot I suspect that my ...
7 years, 4 months ago (2013-08-08 18:28:19 UTC) #8
Nils Barth (inactive)
7 years, 4 months ago (2013-08-09 10:50:19 UTC) #9
Thanks for feedback, and for raising syntax/editor issues.
AFAICT it's generally easier and better behaved *without* an additional
extension, as then it falls back on C++ (with some funny text), rather than
being an unknown ".tmpl" type.

Thanks to this thread, I just added Jinja highlighting to my Vim setup, and it's
actually *easier* if these use the .cpp/.h suffixes (w/o .tmpl), since then I
just add Jinja highlighting on top of the existing C++.

If anyone else is editing these files much and has another (esp. better) system,
I'd be happy to standardize on that.
For editors that can only handle file extensions, .tmpl.cpp/.tmpl.h might be
better, since it has fallback to .cpp/.h.?

Elliot, are you editing these files, or do you know anyone who is?


AFAICT, the reasoning behind Jinja using the extension of the underlying file is
that it's *basically* the underlying file type, with some template additions.
So if you're opening a "Jinja C++ template", usually the best guess is "a C++
file (with some weirdness)", and that's both how you want to edit it and
highlight it.

So calling the file .cpp/.h means it's opened with your usual C++ editor with at
least roughly highlighted correctly.
If it's instead .cpp.tmpl or .h.tmpl, you need to add new file extension, and
then I'd still just get C++ highlighting.
So unless you're doing extra work to get Jinja-specific highlighting, you get no
benefit and additional cost from the extra .tmpl.


For reference, here's what I just whipped up for Vim:
(I'm not Vim expert, but this WFM.)

1. Download Jinja syntax highlighting:
http://www.vim.org/scripts/script.php?script_id=1856
...to ~/.vim/syntax/jinja.vim

2. Put the below in .vimrc

" Per:
" Different syntax highlighting within regions of a file
"
http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file
" ...removing the textSnipHl section (since want to include the delimiters
" for Jinja).
"
" ...and using syntax from:
" http://www.vim.org/scripts/script.php?script_id=1856

function! TextEnableCodeSnip(filetype,start,end) abort
  let ft=toupper(a:filetype)
  let group='textGroup'.ft
  if exists('b:current_syntax') 
    let s:current_syntax=b:current_syntax
    " Remove current syntax definition, as some syntax files (e.g. cpp.vim)
    " do nothing if b:current_syntax is defined.
    unlet b:current_syntax
  endif
  execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
  try
    execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
  catch
  endtry
  if exists('s:current_syntax')
    let b:current_syntax=s:current_syntax
  else
    unlet b:current_syntax
  endif
  execute 'syntax region textSnip'.ft.'
  \ start="'.a:start.'" end="'.a:end.'"
  \ contains=@'.group
endfunction

" Jinja template highlighting
" Default delimiters are {{ }}, {% %}, and {# #}, per:
" http://jinja.pocoo.org/docs/templates/
au BufNewFile,BufRead */templates/* call TextEnableCodeSnip('jinja', '{{', '}}')
au BufNewFile,BufRead */templates/* call TextEnableCodeSnip('jinja', '{%', '%}')
au BufNewFile,BufRead */templates/* call TextEnableCodeSnip('jinja', '{#', '#}')

Powered by Google App Engine
This is Rietveld 408576698