[stringtemplate-interest] Formal parameters in web templates
jimi at temporal-wave.com
Tue Oct 27 08:14:15 PDT 2009
Ah, I see what you mean – well then you can use an interface definition of the templates:
title /* Document this parameter */
group rantG implements RanT;
layout(title) ::= << xxxxxxx $title$ iiiiiii >>
But that really only enforces that interface for templates that implement it. References to templates in the group can pass in the variables or not, as they please, which is sort of the point of it all. There is currently no way to enforce the presence of a parameter (formal attribute) within an instantiation of a template.
From: Ran Tavory [mailto:rantav at gmail.com]
Sent: Tuesday, October 27, 2009 6:39 AM
To: Jim Idle
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Formal parameters in web templates
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.
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.
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.
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:
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.
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the stringtemplate-interest