[stringtemplate-interest] Formal parameters in web templates
Jim Idle
jimi at temporal-wave.com
Tue Oct 27 06:13:11 PDT 2009
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20091027/2ca21a68/attachment.html
More information about the stringtemplate-interest
mailing list