Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(66)

Issue 6482056: code review 6482056: text/template: allow grouping of pipelines using parentheses (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 6 months ago by r
Modified:
12 years, 6 months ago
Reviewers:
CC:
golang-dev, adg, rog, minux1
Visibility:
Public.

Description

text/template: allow grouping of pipelines using parentheses Based on work by Russ Cox. From his CL: This is generally useful but especially helpful when trying to use the built-in boolean operators. It lets you write: {{if not (f 1)}} foo {{end}} {{if and (f 1) (g 2)}} bar {{end}} {{if or (f 1) (g 2)}} quux {{end}} instead of {{if f 1 | not}} foo {{end}} {{if f 1}}{{if g 2}} bar {{end}}{{end}} {{$do := 0}}{{if f 1}}{{$do := 1}}{{else if g 2}}{{$do := 1}}{{end}}{{if $do}} quux {{end}} The result can be a bit LISPy but the benefit in expressiveness and readability for such a small change justifies it. I believe no changes are required to html/template. Fixes issue 3276.

Patch Set 1 #

Patch Set 2 : diff -r 93b44db58f94 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+82 lines, -4 lines) Patch
M src/pkg/text/template/doc.go View 2 chunks +4 lines, -0 lines 0 comments Download
M src/pkg/text/template/exec.go View 2 chunks +4 lines, -0 lines 0 comments Download
M src/pkg/text/template/exec_test.go View 3 chunks +12 lines, -0 lines 0 comments Download
M src/pkg/text/template/parse/lex.go View 7 chunks +23 lines, -2 lines 0 comments Download
M src/pkg/text/template/parse/lex_test.go View 2 chunks +22 lines, -0 lines 0 comments Download
M src/pkg/text/template/parse/node.go View 1 chunk +4 lines, -0 lines 0 comments Download
M src/pkg/text/template/parse/parse.go View 2 chunks +11 lines, -2 lines 0 comments Download
M src/pkg/text/template/parse/parse_test.go View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 6
r
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
12 years, 6 months ago (2012-08-23 19:42:16 UTC) #1
r
Fixes issue 3276.
12 years, 6 months ago (2012-08-23 19:43:09 UTC) #2
adg
LGTM
12 years, 6 months ago (2012-08-24 03:11:30 UTC) #3
rog
On 2012/08/23 19:42:16, r wrote: > Hello mailto:golang-dev@googlegroups.com, > > I'd like you to review ...
12 years, 6 months ago (2012-08-24 07:45:18 UTC) #4
minux1
On Fri, Aug 24, 2012 at 3:42 AM, <r@golang.org> wrote: > Description: > text/template: allow ...
12 years, 6 months ago (2012-08-24 09:33:04 UTC) #5
r
12 years, 6 months ago (2012-08-24 19:37:39 UTC) #6
*** Submitted as http://code.google.com/p/go/source/detail?r=a58536973959 ***

text/template: allow grouping of pipelines using parentheses

Based on work by Russ Cox. From his CL:

        This is generally useful but especially helpful when trying
        to use the built-in boolean operators.  It lets you write:

        {{if not (f 1)}} foo {{end}}
        {{if and (f 1) (g 2)}} bar {{end}}
        {{if or (f 1) (g 2)}} quux {{end}}

        instead of

        {{if f 1 | not}} foo {{end}}
        {{if f 1}}{{if g 2}} bar {{end}}{{end}}
        {{$do := 0}}{{if f 1}}{{$do := 1}}{{else if g 2}}{{$do := 1}}{{end}}{{if
$do}} quux {{end}}

The result can be a bit LISPy but the benefit in expressiveness and readability
for such a small change justifies it.

I believe no changes are required to html/template.

Fixes issue 3276.

R=golang-dev, adg, rogpeppe, minux.ma
CC=golang-dev
http://codereview.appspot.com/6482056
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b