[stringtemplate-interest] Formal parameters in web templates

Todd Stout todd.tstout at gmail.com
Tue Oct 27 06:47:35 PDT 2009


I think StringTemplate's support of group interfaces is what you are looking
for.  Take a look here:
http://www.antlr.org/wiki/display/ST/Group+Files#GroupFiles-Supergroupsandinterfaces
.

On Tue, Oct 27, 2009 at 8:39 AM, Ran Tavory <rantav at gmail.com> wrote:

> Hi Jim, thanks for the reply, but...
> As a web designer, if I have two templates, one of them is layout.st and
> the other is page.st.
>
> layout.st
>
> <html>
> <head>
> <title>$title$</title>
> <body>
> $banner()$
> <hr>
> $body()$
> </body>
> </html>
>
>
> page.st:
>
> $layout(title="My Title")$
>
>
> How can I tell what's expected by layout.st? Of course, I can always
> document that, but it'd be nicer if there was a formal way to do it (tools
> could also use it to hint users).
> I'm not sure I understand why you say this should be a function of the
> model or of the controller.  I don't view this is a "pull" by the view,
> rather as "what can be pushed" to the view.
> At runtime, the view can always complain if some attributes are missing,
> but what would even be nicer is if even before runtime, while editing the
> files, I'd be able to tell whether something's missing or not.
>
> Thanks!
>
>
> On Tue, Oct 27, 2009 at 3:13 PM, Jim Idle <jimi at temporal-wave.com> wrote:
>
>>  That is a function of the model (or possibly controller I suppose), not
>> the view. The view just renders what it is given and can tell if some
>> attributes are not present but that is about it. To enforce what you want,
>> you need to implement some method in your model that is called to populate
>> the view. The controller or model can then enforce what you are asking. In
>> other words, do not crate the template directly, but via an external method
>> that requires parameters , enforces types and throws requisite exceptions.
>>
>>
>>
>> Jim
>>
>>
>>
>>
>>
>>
>>
>> *From:* stringtemplate-interest-bounces at antlr.org [mailto:
>> stringtemplate-interest-bounces at antlr.org] *On Behalf Of *Ran Tavory
>> *Sent:* Monday, October 26, 2009 10:46 PM
>> *To:* stringtemplate-interest at antlr.org
>> *Subject:* [stringtemplate-interest] Formal parameters in web templates
>>
>>
>>
>> A newbe question: Is it possible to define the list of formal parameters
>> in a template where my use case would be for a web page?
>>
>>
>>
>> For example, in this template:
>>
>>
>>
>> layout.st
>>
>>
>>
>> <html>
>>
>> <head>
>>
>> <title>$title$</title>
>>
>> <body>
>>
>> $banner()$
>>
>> <hr>
>>
>> $body()$
>>
>> </body>
>>
>> </html>
>>
>>
>> I'd like to say that *$title$* is a required parameter. Would even be
>> better if types can be enforced, such as String, Number, Date, List of x
>> etc, but even without static typing, simply listing the formal arguments the
>> template expects would be great.
>>
>> Thanks!
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>
>>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20091027/16ab07b3/attachment-0001.html 


More information about the stringtemplate-interest mailing list