• Rob Pike's avatar
    text/template: provide a way to trim leading and trailing space between actions · e6ee26a0
    Rob Pike authored
    Borrowing a suggestion from the issue listed below, we modify the lexer to
    trim spaces at the beginning (end) of a block of text if the action immediately
    before (after) is marked with a minus sign. To avoid parsing/lexing ambiguity,
    we require an ASCII space between the minus sign and the rest of the action.
    Thus:
    
    	{{23 -}}
    	<
    	{{- 45}}
    
    produces the output
    	23<45
    
    All the work is done in the lexer. The modification is invisible to the parser
    or any outside package (except I guess for noticing some gaps in the input
    if one tracks error positions). Thus it slips in without worry in text/template
    and html/template both.
    
    Fixes long-requested issue #9969.
    
    Change-Id: I3774be650bfa6370cb993d0899aa669c211de7b2
    Reviewed-on: https://go-review.googlesource.com/14391Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
    e6ee26a0
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...