<div dir="ltr">Hi Todd, I've read this page 10 times I think... ;)<div>Perhaps what I'm looking for is hiding in the BNF on the page, I have to admit my BNFish is a bit rusty...</div><div>Anyhow, I see how templates such as this list their parameters:</div>
<div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; line-height: 17px; "><pre class="code-java" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-align: left; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; line-height: 1.3; ">
vardef(type,name) ::= <span class="code-quote" style="color: rgb(0, 145, 0); background-color: inherit; ">"<type> <name>;"</span></pre></span></div><div>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. </div>
<div>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.</div>
<div>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 :)</div><div><br><br><div class="gmail_quote">On Tue, Oct 27, 2009 at 3:47 PM, Todd Stout <span dir="ltr"><<a href="mailto:todd.tstout@gmail.com">todd.tstout@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I think StringTemplate's support of group interfaces is what you are looking for. Take a look here: <a href="http://www.antlr.org/wiki/display/ST/Group+Files#GroupFiles-Supergroupsandinterfaces" target="_blank">http://www.antlr.org/wiki/display/ST/Group+Files#GroupFiles-Supergroupsandinterfaces</a>.<div>
<div></div><div class="h5"><br>
<br><div class="gmail_quote">On Tue, Oct 27, 2009 at 8:39 AM, Ran Tavory <span dir="ltr"><<a href="mailto:rantav@gmail.com" target="_blank">rantav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Hi Jim, thanks for the reply, but...</div>As a web designer, if I have two templates, one of them is <a href="http://layout.st" target="_blank">layout.st</a> and the other is <a href="http://page.st" target="_blank">page.st</a>.<div>
<div><br>
</div><div><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse"><div><a href="http://layout.st/" style="color:rgb(237, 28, 36)" target="_blank">layout.st</a></div>
<div><span style="font-family:Courier, arial, sans-serif;font-size:12px;line-height:13px"><pre style="white-space:pre-wrap;word-wrap:break-word;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:5px;margin-left:15px;margin-bottom:5px;margin-right:5px;text-align:left">
<html>
<head>
<title>$title$</title>
<body>
$banner()$
<hr>
$body()$
</body>
</html></pre><pre style="white-space:pre-wrap;word-wrap:break-word;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:5px;margin-left:15px;margin-bottom:5px;margin-right:5px;text-align:left">
<br></pre></span></div></span></div></div><div><a href="http://page.st" target="_blank">page.st</a>:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><span style="font-family:Courier, arial, sans-serif;font-size:12px;border-collapse:collapse;line-height:13px"><pre style="white-space:pre-wrap;word-wrap:break-word;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:5px;margin-left:15px;margin-bottom:5px;margin-right:5px;text-align:left">
$layout(title="My Title")$</pre></span></blockquote><div><br></div><div>How can I tell what's expected by <a href="http://layout.st" target="_blank">layout.st</a>? 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). </div>
<div>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.</div>
<div>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.</div>
<div><br></div><div>Thanks!</div><div><br></div><div><br><div class="gmail_quote"><div><div></div><div>On Tue, Oct 27, 2009 at 3:13 PM, Jim Idle <span dir="ltr"><<a href="mailto:jimi@temporal-wave.com" target="_blank">jimi@temporal-wave.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">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.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Jim</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt">
<a href="mailto:stringtemplate-interest-bounces@antlr.org" target="_blank">stringtemplate-interest-bounces@antlr.org</a>
[mailto:<a href="mailto:stringtemplate-interest-bounces@antlr.org" target="_blank">stringtemplate-interest-bounces@antlr.org</a>] <b>On Behalf Of </b>Ran
Tavory<br>
<b>Sent:</b> Monday, October 26, 2009 10:46 PM<br>
<b>To:</b> <a href="mailto:stringtemplate-interest@antlr.org" target="_blank">stringtemplate-interest@antlr.org</a><br>
<b>Subject:</b> [stringtemplate-interest] Formal parameters in web templates</span></p>
</div>
</div><div><div></div><div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">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?</p>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">For example, in this template:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"><a href="http://layout.st" target="_blank">layout.st</a></p>
</div>
<div><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"> </pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"><html></pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt">
<head></pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"><title>$title$</title></pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"><body></pre>
<pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt">$banner()$</pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"><hr></pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt">
$body()$</pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"></body></pre><pre style="margin-right:3.75pt;margin-bottom:3.75pt;margin-left:11.25pt"></html></pre>
<p class="MsoNormal"><span><br>
<span>I'd like to say that <b>$title$</b> 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.</span></span></p>
</div>
<div>
<p class="MsoNormal"><span>Thanks!</span></p>
</div>
</div>
</div></div></div>
</div>
</div>
<br></div></div>_______________________________________________<br>
stringtemplate-interest mailing list<br>
<a href="mailto:stringtemplate-interest@antlr.org" target="_blank">stringtemplate-interest@antlr.org</a><br>
<a href="http://www.antlr.org/mailman/listinfo/stringtemplate-interest" target="_blank">http://www.antlr.org/mailman/listinfo/stringtemplate-interest</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
stringtemplate-interest mailing list<br>
<a href="mailto:stringtemplate-interest@antlr.org" target="_blank">stringtemplate-interest@antlr.org</a><br>
<a href="http://www.antlr.org/mailman/listinfo/stringtemplate-interest" target="_blank">http://www.antlr.org/mailman/listinfo/stringtemplate-interest</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div><br></div></div>