Hi, Ivan+group--
On Wed, Mar 13, 2013 at 6:39 PM, Ivan Raikov <[email protected]>wrote:
>
> 1) {% endblock <block_name> %}: the current grammar does not accept
> identifiers after endblock. Is this something required by Jinja?
>
It's not required, but it's allowed. And, as should be obvious, it doesn't
really do anything, just possibly makes the template structure more
readable.
3) {% if not loop.last %}: this should work. Can you check whether "if
loop.last" works?
Okay, I just tried the following two templates:
A)
{% for word in words %}
{{ word }}{% if loop.last %}!{% endif %}
{% endfor %}
B)
{% for word in words %}
{{ word }}{% if not loop.last %},{% endif %}
{% endfor %}
A works for me, but B does not. The error looks like this:
Error: (ident-expr->name) invalid identifier expression: #<texpr>
Call history:
runtime.scm:52: loop
runtime.scm:50: utf8#string-length
runtime.scm:52: loop
runtime.scm:50: utf8#string-length
runtime.scm:961: Tstr
runtime.scm:325: tmpl-ctx-buffer
runtime.scm:324: display
ersatz-lib.scm:204: datatype#invoke-variant-case
ersatz-lib.scm:204: display
eval.scm:291: eval-statement
eval.scm:238: datatype#invoke-variant-case
eval.scm:280: select-case
eval.scm:275: eval-expr
eval.scm:25: datatype#invoke-variant-case
eval.scm:84: ident-expr->name
runtime.scm:125: error <--
I thought the error I got before was in the parser, but I'm not really sure
now. I ran the current exercise in CSI, whereas the code I had trouble with
before was compiled. By the way, I have Chicken 4.8.0.1 on Arch Linux
32-bit, with Ersatz 1.3.
5) Tvalues: I am an SML/Ocaml groupie and fanatical believer in types :-D
> But if it will help, I will add a sexpr->tvalue and tvalue->sexpr
> procedures that can convert between Scheme values and template values.
>
I wouldn't mind that.
> 6) Yes, you can build templates "in-memory". Take a look at the
> template-statement data type. I will add this to the documentation as well.
>
Okay; I thought that might be the case, but I didn't really understand how
to use statements. Maybe now that I've used the library a bit, I'll take
another look at statements.
> 7) Name: 'tori' is a bit too generic, I think. Presumably German is the
> native language of Chicken, so I chose what I think expresses the nature of
> templates, yet is somewhat self-deprecating, as ersatz usually means 'poor
> substitute' in English and my native Bulgarian.
>
Not tori, torii! Okay, I'll explain this. You didn't say whether you got my
(possibly not-so-funny) joke or not, but perhaps others will find it
slightly amusing.
So, this templating library is derived from Jinja. Jinja in Japanese means
a Shinto shrine (and by the way, certain shrines are called "jingu"--hence
the name of the OCaml library, Jingoo). Well, most Shinto shrines have a
distinctive type of gateway called a *torii*--I'm sure everyone here has
seen pictures of them. And note the double 'i'--that signifies a long, or
more precisely, doubled vowel sound. Well, now, consider the word 'tori'
(with a single 'i'). The fundamental meaning of *tori* is 'bird'--however,
when used in reference to food, it usually means a particular kind of bird:
chicken!
So there you have it! I think it's pretty clever, but if you really prefer
Ersatz, I guess I can live with that. But be warned: if you ever get tired
of maintaining the egg and I happen to take it over, I will probably change
the name (<evil laughter>).
Oh, and by the way [if you're not a (human) language geek, you can skip
this part], I am curious as to whether my pun makes sense to Japanese
people. See, the distinction between the long and short vowel sounds (as in
*torii* vs. *tori*) is often difficult for non-native Japanese
speakers--they really sound very similar if your ears are not accustomed to
it. Yet, whenever I have complained about this to Japanese people, their
response is almost invariable some version of "What do you mean? They're
completely different." On the other hand, I'm pretty sure I have heard
Japanese comedians on a number of occasions making puns in exactly this way.
--
Matt Gushee
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users