 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Karsten Hoffmann
RE: Some questions [ reply ] 2006-02-08 15:24
|
Brian and Greg,
many thanks for your help. Now I can go on.
I think a comprehensive documentation is not necessary. A short summary including all directives and an example per directive (like in your answer) would be fine.
Karsten
|
By: Greg Millam
RE: Some questions [ reply ] 2006-02-07 20:24
|
Q1: I want to iterate over a simple list, e.g. [ 1 2 3 ] without creating a hash. Is it possible with the [%in ...%] directive? If so, how?
[% in colors: color %] [% var color %] Fish [% end %]
This works for nested lists, arrays, etc:
Q2: What's with a nested list? E.g. [ [1,2], [3,4] ]
[% in mynestedlist: first,second %]
or
[% in mylist.1.2 %] (Gets you mylist[0][2])
S1: As Wisti said, this is our stylistic choice. I did create the casecommand. (require 'PageTemplate/case') [% case value %] [% when literal %] ... [% end %]
We also allow method calls: [% if count.zero? %]Countdown complete![% end %]
S2: See Q1 and Q2.
Terribly sorry about our poor documentation for newer features. I meant to get around to it, but things came up, then I plain forgot. I'll get on it. Thanks for the reminder!
|
By: Brian Wisti
RE: Some questions [ reply ] 2006-02-07 20:01
|
Q1. (Iterating over literals)
It's a stylistic thing. I don't like using a literal in my template code, because that takes control away from my application code. I want to know exactly what to expect from my designers, and that's why I try to keep the power of a template as low as possible. Greg is a little more flexible on this count. If he wants to put this in (or has already, I lost track of all the stuff he's done), I'm not going to stop him. It's just not on the official "To Do" list.
Q2. (Something about nested lists)
I don't know, what *is* with a nested list? :) I don't think I understand this question.
S1. (Syntax changes)
This style is more difficult for me personally, because I am usually looking at my templates as HTML with some lightweight placeholders thrown in. This style looks more like code and HTML freely mingling. But you could create your own syntax if you wanted. This is something we should document a lot more.
S2. (Named Iterator)
Actually, I think Greg put something like this in place a little while ago. Greg?
|
By: Karsten Hoffmann
Some questions [ reply ] 2006-02-07 19:49
|
First of all: Thanks for this great package.
Now two questions (Q) and a suggestion(S):
Q1. I want to iterate over a simple list, e.g. [ 1 2 3 ] without creating a hash. Is it possible with the [%in ...%] directive? If so, how?
Q2. What's with a nested list? E.g. [ [1,2], [3,4] ]
S1. Wasn't it easier to use the following syntax(borrowed from the Cheetah template engine):
#if $var_name == SOME_CONDITION
...
#end if
S2. Is it possible to introduce a [%for VAR in LIST%] directive with the possiblity to assign values from nested lists directly into variables. E.g.
my_list = [ [1,2], [3,4] ]
[%for ([%var a%], [%var b%]) in my_list%]
[%endfor%]
Thanks in advance.
Karsten
|
|
 |