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

Issue 2680123002: Add Jinja2 macro for adding trailing strings. (Closed)

Created:
3 years, 10 months ago by shend
Modified:
3 years, 10 months ago
CC:
blink-reviews, blink-reviews-style_chromium.org, chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add Jinja2 macro for adding trailing strings. There's a lot of repetitive code in ComputedStyleBase.h.tmpl to handle formatting. For example, the member initialiser list in the generated constructor needs a trailing comma for every member except the last one. This patch moves such code into a generic macro in macros.tmpl, which which makes it available for other templates. This will be used more frequently when we start introducing more complexity to the ComputedStyle templates. BUG=628043 Review-Url: https://codereview.chromium.org/2680123002 Cr-Commit-Position: refs/heads/master@{#450173} Committed: https://chromium.googlesource.com/chromium/src/+/c0a8bdbcd693f00a522afa34e5bdceb3129bb1da

Patch Set 1 #

Total comments: 3

Patch Set 2 : Change to print_if #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -17 lines) Patch
M third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl View 1 4 chunks +16 lines, -17 lines 4 comments Download
M third_party/WebKit/Source/build/scripts/templates/macros.tmpl View 1 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 27 (9 generated)
shend
Hi Bugs, PTAL
3 years, 10 months ago (2017-02-08 22:18:28 UTC) #2
Bugs Nash
lgtm
3 years, 10 months ago (2017-02-09 02:46:43 UTC) #3
shend
Hi Eddy, PTAL :)
3 years, 10 months ago (2017-02-09 21:26:24 UTC) #5
Bugs Nash
lgtm
3 years, 10 months ago (2017-02-12 22:48:20 UTC) #7
Bugs Nash
On 2017/02/12 at 22:48:20, Bugs Nash wrote: > lgtm I swear I didn't just do ...
3 years, 10 months ago (2017-02-12 22:50:24 UTC) #8
shend
Hi Eddy, PTAL
3 years, 10 months ago (2017-02-13 00:36:50 UTC) #10
meade_UTC10
lgtm Nice fix! One small comment. https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl File third_party/WebKit/Source/build/scripts/templates/macros.tmpl (right): https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl#newcode60 third_party/WebKit/Source/build/scripts/templates/macros.tmpl:60: {% macro trailing(loop, ...
3 years, 10 months ago (2017-02-13 06:19:59 UTC) #11
shend
https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl File third_party/WebKit/Source/build/scripts/templates/macros.tmpl (right): https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl#newcode60 third_party/WebKit/Source/build/scripts/templates/macros.tmpl:60: {% macro trailing(loop, str) -%} On 2017/02/13 at 06:19:58, ...
3 years, 10 months ago (2017-02-13 06:40:37 UTC) #12
meade_UTC10
https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl File third_party/WebKit/Source/build/scripts/templates/macros.tmpl (right): https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl#newcode60 third_party/WebKit/Source/build/scripts/templates/macros.tmpl:60: {% macro trailing(loop, str) -%} On 2017/02/13 06:40:37, shend ...
3 years, 10 months ago (2017-02-13 06:51:15 UTC) #13
shend
On 2017/02/13 at 06:51:15, meade wrote: > https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl > File third_party/WebKit/Source/build/scripts/templates/macros.tmpl (right): > > https://codereview.chromium.org/2680123002/diff/1/third_party/WebKit/Source/build/scripts/templates/macros.tmpl#newcode60 ...
3 years, 10 months ago (2017-02-13 06:59:39 UTC) #14
shend
On 2017/02/13 at 06:59:39, shend wrote: > On 2017/02/13 at 06:51:15, meade wrote: > > ...
3 years, 10 months ago (2017-02-13 07:03:09 UTC) #15
blink-reviews
Both sound good! print_if_not(foo) vs print_if(not foo) seem so similar that I don't mind :p ...
3 years, 10 months ago (2017-02-13 07:07:19 UTC) #16
chromium-reviews
Both sound good! print_if_not(foo) vs print_if(not foo) seem so similar that I don't mind :p ...
3 years, 10 months ago (2017-02-13 07:07:20 UTC) #17
shend
On 2017/02/13 at 07:07:20, chromium-reviews wrote: > Both sound good! > print_if_not(foo) vs print_if(not foo) ...
3 years, 10 months ago (2017-02-13 07:19:56 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2680123002/20001
3 years, 10 months ago (2017-02-13 21:42:13 UTC) #21
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/chromium/src/+/c0a8bdbcd693f00a522afa34e5bdceb3129bb1da
3 years, 10 months ago (2017-02-14 00:40:45 UTC) #24
sashab
Ahh <3 this patch. \o/ https://codereview.chromium.org/2680123002/diff/20001/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl File third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl (right): https://codereview.chromium.org/2680123002/diff/20001/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl#newcode14 third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl:14: {% macro default_value(field) -%} ...
3 years, 10 months ago (2017-02-19 23:17:03 UTC) #26
shend
3 years, 10 months ago (2017-02-19 23:20:17 UTC) #27
Message was sent while issue was closed.
https://codereview.chromium.org/2680123002/diff/20001/third_party/WebKit/Sour...
File third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl
(right):

https://codereview.chromium.org/2680123002/diff/20001/third_party/WebKit/Sour...
third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl:14:
{% macro default_value(field) -%}
On 2017/02/19 at 23:17:03, sashab wrote:
> What's the dashes for?

They strip out leading/trailing whitespace so you can write the {% macro %}
stuff on a separate line without introducing excess new lines in the generated
code.

https://codereview.chromium.org/2680123002/diff/20001/third_party/WebKit/Sour...
third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl:27:
{{field.name}}({{default_value(field)}}){{print_if(not loop.last, ',')}}
On 2017/02/19 at 23:17:03, sashab wrote:
> Woah loop.last awesome!!

\o/

Powered by Google App Engine
This is Rietveld 408576698