[stringtemplate-interest] IDE support and an issue with anested list of Java objects
John Snyders
jjsnyders at rcn.com
Tue Jan 16 06:47:39 PST 2007
A template cannot call any methods. This would break the seperation between
model and view. This is intentional. See
http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf sections 7 and 7.1.
All data the view will use needs to be calculated before calling the
template.
I'm not sure what you are trying to do by calling a method. lowerName sounds
like a property. If you are trying to change the value of column c to
lowercase then there are a few ways to do this. The new format option could
be used but I don't know if it is available in a stable build. It would look
like this $c;format="lowercase"$ and you have to write the code to do the
lowercase in a renderer. If you always want the columns in lowercase
(probably not) you can wrap them in an object where the toString method does
the lowercase. You can also create pseudo properties on the column object
that does the formating. If c is a column object that holds the value of the
column create a getLowerName() getter property method which does the
lowercase (or whatever other formatting you want) on the column value.
-John
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org]On Behalf Of Shane Witbeck
Sent: Tuesday, January 16, 2007 12:00 AM
To: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] IDE support and an issue with
anested list of Java objects
Although I've had some help from Terence, I'm still having an issue with
the first of my two questions. I'm iterating over a list of "table" objects
and for each table object I have a list of column objects.
His solution was something like this:
$tables:{
public $it.capitalizedName$ get$it.capitalizedName$(int id) throws
DataAccessException {
String sql = "select $it.columns{c | $c.lowerName()$}; separator=", "$
from $it.allLowerName$ where ID = ?";
I think he made the assumption that c.lowerName() is a call to a nested
template. What I really need it to do is to invoke a "lowerName()" method on
the column object like I'm doing in the iteration of tables above it. Not
sure if I'm unaware of a limitation or if I have the syntax wrong.
Thanks again.
On 1/14/07, Shane Witbeck <shane at digitalsanctum.com> wrote:
Two questions:
1. Is there a "File Type" definition or plugin available for
StringTemplate somewhere which gives highlighting support for the IntelliJ
IDEA IDE? If not, which IDE has the best support for working with templates?
2. I'm getting the string representation of a nested object list instead
of the value of the method I'm calling.
Here's the code in question:
$tables:{
public $it.capitalizedName$ get$it.capitalizedName$(int id) throws
DataAccessException {
String sql = "select $it.columns; separator=", ":{
$it.capitalizedName$ }$ from $it.allLowerName$ where ID = ?";
which generates this:
public Attribute getAttribute(int id) throws DataAccessException {
String sql = "select
com.digitalsanctum.tools.DomainGenerator$Column at 125d06e,
com.digitalsanctum.tools.DomainGenerator$Column at 196f4b5 from attribute where
ID = ?";
tables is a List<Table> and columns (List<Column>) is a member variable
of a Table object.
TIA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070116/2bf4b126/attachment.html
More information about the stringtemplate-interest
mailing list