<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Thoughts on StringTemplate part 2</title>
	<atom:link href="http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/</link>
	<description>The writings of John Snyders, mostly about software.</description>
	<lastBuildDate>Thu, 13 Oct 2011 15:18:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Florin T.PATRASCU</title>
		<link>http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/comment-page-1/#comment-1506</link>
		<dc:creator>Florin T.PATRASCU</dc:creator>
		<pubDate>Fri, 24 Aug 2007 04:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/#comment-1506</guid>
		<description>John - thank you for the extra clarifications. I like the second method and I believe that this method is more in agreement with the philosophy driving ST. Meanwhile, I am processing my repository calls in a page Action and make the content available to the ST context as a normal variable. A bit of extra code, but now I believe I know how to optimize my JPublish-ST integration. Here is a bit of the details: http://weblog.flop.ca/2007/08/23/1187872320000.html

There is also a simple web app demo using ST for web pages, demo that you can download from here: http://jpublish.googlecode.com/files/stdemo.war.zip, in case you&#039;re interested. Any feedback will be highly appreciated.

Many thanks!
-florin</description>
		<content:encoded><![CDATA[<p>John &#8211; thank you for the extra clarifications. I like the second method and I believe that this method is more in agreement with the philosophy driving ST. Meanwhile, I am processing my repository calls in a page Action and make the content available to the ST context as a normal variable. A bit of extra code, but now I believe I know how to optimize my JPublish-ST integration. Here is a bit of the details: <a href="http://weblog.flop.ca/2007/08/23/1187872320000.html" rel="nofollow">http://weblog.flop.ca/2007/08/23/1187872320000.html</a></p>
<p>There is also a simple web app demo using ST for web pages, demo that you can download from here: <a href="http://jpublish.googlecode.com/files/stdemo.war.zip" rel="nofollow">http://jpublish.googlecode.com/files/stdemo.war.zip</a>, in case you&#8217;re interested. Any feedback will be highly appreciated.</p>
<p>Many thanks!<br />
-florin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Snyders</title>
		<link>http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/comment-page-1/#comment-1498</link>
		<dc:creator>John Snyders</dc:creator>
		<pubDate>Thu, 23 Aug 2007 14:33:52 +0000</pubDate>
		<guid isPermaLink="false">http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/#comment-1498</guid>
		<description>Thanks, I&#039;m glad my articles are helpful.

Questions like this are best asked on the stringtemplate mailing list over at http://www.stringtemplate.org/. Anyone using stringtemplate should subscribe to the mailinglist.

I&#039;ll try to answer your question but if it isn&#039;t sufficient you can move it to the list.

A very important feature of ST is that you can&#039;t call arbitrary methods. repository.get(String path) is a method call. The reason is that methods can have side effects (properties can too but they usually don&#039;t and shouldn&#039;t). Calling a method can violate the push strategy - see section 7.1 in the &quot;Enforcing Strict ModelView Separation in Template Engines&quot; paper that says all data used by the template must be computed prior to invoking the template. 

It looks like you are using the repository like a map. If the information in the repository is computed and available before the template is processed and getting a path has no side effects then you should be able to get at the data from the template. I can think of two ways to do this. 

1) expose the structure of the repository as individual objects to ST so that you can access information as $repository.path.to.a.resource$. ST supports indirect property references but for one property at a time: $repository.(part1).(part2)$ will work but $repository.(path)$ will not. If it is common in your system to have paths that specify the property then option 1 may not be right for you. 

2) treat the repository as a map. You will need to implement a map wrapper around your repository. The path then becomes a key into the map. $repository.(&quot;path/to/a/resource&quot;)$ would return the desired value. From ST point of view repository is a map and &quot;path/to/a/resource&quot; is a key. If your paths support complex expressions like XPath in XML then you need to think hard about model view separation and if you are breaking it.

A third less desirable option would be to modify ST so that it directly supported your path syntax.</description>
		<content:encoded><![CDATA[<p>Thanks, I&#8217;m glad my articles are helpful.</p>
<p>Questions like this are best asked on the stringtemplate mailing list over at <a href="http://www.stringtemplate.org/" rel="nofollow">http://www.stringtemplate.org/</a>. Anyone using stringtemplate should subscribe to the mailinglist.</p>
<p>I&#8217;ll try to answer your question but if it isn&#8217;t sufficient you can move it to the list.</p>
<p>A very important feature of ST is that you can&#8217;t call arbitrary methods. repository.get(String path) is a method call. The reason is that methods can have side effects (properties can too but they usually don&#8217;t and shouldn&#8217;t). Calling a method can violate the push strategy &#8211; see section 7.1 in the &#8220;Enforcing Strict ModelView Separation in Template Engines&#8221; paper that says all data used by the template must be computed prior to invoking the template. </p>
<p>It looks like you are using the repository like a map. If the information in the repository is computed and available before the template is processed and getting a path has no side effects then you should be able to get at the data from the template. I can think of two ways to do this. </p>
<p>1) expose the structure of the repository as individual objects to ST so that you can access information as $repository.path.to.a.resource$. ST supports indirect property references but for one property at a time: $repository.(part1).(part2)$ will work but $repository.(path)$ will not. If it is common in your system to have paths that specify the property then option 1 may not be right for you. </p>
<p>2) treat the repository as a map. You will need to implement a map wrapper around your repository. The path then becomes a key into the map. $repository.(&#8220;path/to/a/resource&#8221;)$ would return the desired value. From ST point of view repository is a map and &#8220;path/to/a/resource&#8221; is a key. If your paths support complex expressions like XPath in XML then you need to think hard about model view separation and if you are breaking it.</p>
<p>A third less desirable option would be to modify ST so that it directly supported your path syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florin T.PATRASCU</title>
		<link>http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/comment-page-1/#comment-1454</link>
		<dc:creator>Florin T.PATRASCU</dc:creator>
		<pubDate>Tue, 21 Aug 2007 12:04:13 +0000</pubDate>
		<guid isPermaLink="false">http://hardlikesoftware.com/weblog/2007/06/25/thoughts-on-stringtemplate-part-2/#comment-1454</guid>
		<description>First of all thank you for the detailed articles regarding StringTemplate. They are a guide for me and because of these articles I decided to learn StringTemplate. More than that, I decided to add StringTemplate as a View renderer to JPublish (http://code.google.com/p/jpublish/) and I believe I am days away of releasing it. With JPublish you can simply define your site with StringTemplate files and JPublish Actions. 

Right now I have a really silly question but is not obvious to me how can I do the following thing in ST:
- let&#039;s say I have an Object called &#039;repository&#039; and this object has a get method repository.get( String resourceName). I cannot figure out how can I get access to this method in a ST?! (Jpublish will inject this object in the ST context before rendering a ST file)

I would like to write:
$repository.get( &quot;path/to/a/resource&quot;)$ or something a bit more complicated, where the resource is a variable: $repository.get ( page.getPath())$, where page is another object present in the ST context.

Can I even do all these? In Velocity (the default template language of JPublish) I can simply do this: $repository.get( $page.Path)


Thank you!
-florin</description>
		<content:encoded><![CDATA[<p>First of all thank you for the detailed articles regarding StringTemplate. They are a guide for me and because of these articles I decided to learn StringTemplate. More than that, I decided to add StringTemplate as a View renderer to JPublish (<a href="http://code.google.com/p/jpublish/" rel="nofollow">http://code.google.com/p/jpublish/</a>) and I believe I am days away of releasing it. With JPublish you can simply define your site with StringTemplate files and JPublish Actions. </p>
<p>Right now I have a really silly question but is not obvious to me how can I do the following thing in ST:<br />
- let&#8217;s say I have an Object called &#8216;repository&#8217; and this object has a get method repository.get( String resourceName). I cannot figure out how can I get access to this method in a ST?! (Jpublish will inject this object in the ST context before rendering a ST file)</p>
<p>I would like to write:<br />
$repository.get( &#8220;path/to/a/resource&#8221;)$ or something a bit more complicated, where the resource is a variable: $repository.get ( page.getPath())$, where page is another object present in the ST context.</p>
<p>Can I even do all these? In Velocity (the default template language of JPublish) I can simply do this: $repository.get( $page.Path)</p>
<p>Thank you!<br />
-florin</p>
]]></content:encoded>
	</item>
</channel>
</rss>

