[stringtemplate-interest] Formal parameters in web templates
Ran Tavory
rantav at gmail.com
Tue Oct 27 07:00:32 PDT 2009
Hi Todd, I've read this page 10 times I think... ;)
Perhaps what I'm looking for is hiding in the BNF on the page, I have to
admit my BNFish is a bit rusty...
Anyhow, I see how templates such as this list their parameters:
vardef(type,name) ::= "<type> <name>;"
But I figured this sort of notation seems unnatural to web pages, so I was
wondering if there's a more appropriate web-page-friendly notation.
What also got me confused is that all ST web-page examples seem to use a
different notation style. None of them contain tokens such as ::= for
example, and none of them define the group name, so I was wondering if this
those notations are indeed equivalent.
And to mention again - I've only heard of ST 3 days ago, so this is a newbe
question, if there's something trivial I'm missing feel free to point me at
it :)
On Tue, Oct 27, 2009 at 3:47 PM, Todd Stout <todd.tstout at gmail.com> wrote:
> 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/0c720490/attachment.html
More information about the stringtemplate-interest
mailing list