Re: [Boost-docs] [Gaea] Named optional attributes

Subject: Re: [Boost-docs] [Gaea] Named optional attributes
From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2011-11-01 23:29:46


On Tue, Nov 1, 2011 at 3:52 PM, Joel de Guzman
<joel_at_[hidden]> wrote:
> On 11/1/2011 7:41 PM, Matias Capeletto wrote:
>> Talking about optional arguments, have you think about using it for
>> the if template?
>
> Interesting, but let's keep it as simple as possible.

No problem. One thing that bugs me about the current definition of if
is that doesn't work like other templates because you can call it with
two or three parameters. To be a real template it should be defined in
the specs as [decl [if cond . branchs]]. But maybe it is somewhat
nitpicking :)

> BTW, I added variables. This is the solution to the footnote
> issue. Just allow for variables where we can collect the
> footnotes and expand them where needed.
>
> The latest spec: http://pastebin.com/dDP4peAd

Nice... I was waiting to see what you were thinking about this.
I do not know if I fully understand how it supposed to work. These
variables are not intended to be used as arguments of other templates,
but as a way to create some kind of global variables accessibly by all
other templates?

[def [unfold . things] [fold [things][][rcat]]]

[var footnotes-list []]

[def [section name . blocks]
  [set footnotes-list []]
  <section>
    <title>[name]</title>
    [unfold [blocks]]
  </section>
  <footnotes>
    [unfold [footnotes-list]]
  </footnotes>
]

[def [footnote text]
  [def [footnote-id] [size [footnotes-list]]]
  <footnoteref id=[footnote-id]/>
  [set footnotes-list [append [footnotes-list] [[footnote-id] :: [text]]]
]

It feels a little bit strange, but maybe is just the first impression.
Do you have any other use cases?

> I think we're almost there. I've reread the StringTemplate
> engine docs, and I must say, this is so much better in
> terms of purity and elegance of syntax. 'fcourse I'm biased :)

parens(x) ::= "(<x>)"
"text":parens() // => (text)

[def [parens x] ([x])]
[parens text] [/ => (text) ]

:)

Best regards
Matias


This archive was generated by hypermail 2.1.7 : 2017-11-11 08:50:41 UTC