[stringtemplate-interest] How to write a helper template/macro for common stuff in a template (i.e. model and controller independent)
Terence Parr
parrt at cs.usfca.edu
Thu Jul 16 21:08:47 PDT 2009
Hi Barrie,
I think <RETYPE(v="3")> would do it. then define RETYPE to take v as
parameter.
Ter
On Jul 16, 2009, at 8:16 PM, Barrie Treloar wrote:
> 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
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list