[stringtemplate-interest] How to write a helper template/macro for common stuff in a template (i.e. model and controller independent)
Barrie Treloar
baerrach at gmail.com
Thu Jul 16 20:16:04 PDT 2009
I have output in my template that is common enough that I would like
to refactor this out (avoid typing/typos)
In the example below I would like to create a template to replace the
RETYPE lines with a template call.
Something like
<RETYPE(3)>
which would iterate over the template
RETYPE [<it>] 0
But I can only do this from attributes passed into the view from the model.
And in this case the output is model independent.
Anyone have suggestions on how to do this?
e.g.
S | ? | S | \& ; T1 Agnes Road
COPY_A [1] temp
CONCAT " " temp
CONCAT [2] temp
COPY temp {S1}
COPY "STREET" {T1}
RETYPE [1] 0
RETYPE [2] 0
RETYPE [3] 0
RETURN
S | ? | T | D | \& ; T1 Agnes Court West
COPY_A [1] temp
CONCAT " " temp
CONCAT [2] temp
COPY temp {S1}
COPY_A [3] {T1}
COPY_A [4] {D1}
RETYPE [1] 0
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0
RETURN
S | ? | T | D | ** | \& ; T1 Agnes Court West
COPY_A [1] temp
CONCAT " " temp
CONCAT [2] temp
COPY temp {S1}
COPY_A [3] {T1}
COPY_A [4] {D1}
COPY_S [5] {Z1}
RETYPE [1] 0
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0
RETYPE [5] 0
RETURN
More information about the stringtemplate-interest
mailing list