[stringtemplate-interest] problem with first(attribute) expression when attribute is a list of hashes
Matt Brown
matt at thataddress.com
Sat Dec 15 12:18:02 PST 2007
Yes, I am sure it's non-null, and hash_member isn't the actual key...I'm
not sure why I changed the names. Here's the relevant part of the
actual template (a page that lists results of a tag search):
$if(index)$
<h3>Pages matching tag '$first(index).tag_text$':</h3>
<ul>
$index:{<li><a href="$contextRoot$/$it.section_id$/view/$it.page_id
$">$it.title$</a> [$it.section_id$]</li>}$
</ul>
$endif$
And here's the value of "index" from one of my tests (obtained via
toDebugString):
index=[{page_id=1296, title=music review ho!, tag_text=beer,
section_id=music}, {page_id=1186, title=Animation Runner Kuromi 2,
tag_text=beer, section_id=reviews}]
If I remove the attribute reference from the "h3" block, the list below
it renders properly.
Thanks,
- Matt Brown
On Fri, 2007-12-14 at 11:56 -0800, Terence Parr wrote:
> hmm..strange. So you are sure that list_attribute[0] is non null? Is
> "hash_member" a valid key, btw?
>
> Ter
> On Dec 14, 2007, at 11:40 AM, matt at thataddress.com wrote:
>
> >
> >
> > Hello list (new here),
> >
> > I have a web page where I stuff a List
> > of HashMap into a string template, and I want to use one of the
> > members of
> > the first hash in the list. So I tried:
> >
> > $first(list_attribute).hash_member$
> >
> > This resulted in a
> > NullPointerException in ConditionalExpr.write (line 88).
> >
> > Then I
> > tried:
> >
> > $first(list_attribute):{ $it.hash_member$ }$
> >
> > This approach resulted in an empty string (and I verified that the
> > member I want to reference is in fact passed into the template). Is
> > there some other way to do what I want, that I'm missing? I'm using
> > StringTemplate 3.1b1.
> >
> > - Matt Brown
> >
> >
> > _______________________________________________
> > stringtemplate-interest mailing list
> > stringtemplate-interest at antlr.org
> > http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
More information about the stringtemplate-interest
mailing list