[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question about cosmo
- From: Wesley Smith <wesley.hoke@...>
- Date: Tue, 19 Jan 2010 07:07:44 +0100
You can do $name{}_new.
wes
On Tue, Jan 19, 2010 at 1:11 AM, Fabio Mascarenhas <mascarenhas@acm.org> wrote:
> On Mon, Jan 18, 2010 at 9:38 PM, Graham Wakefield
> <wakefield@mat.ucsb.edu> wrote:
>> I would like to fill a template in which the insertion point is directly
>> followed by an underscore; is there a way to convince cosmo to do it?
>>
>> e.g.
>> local template = "function $name_new"
>
> local template = "function $name{}_new"
>
>> local fields = { name = "foo" }
>> print(cosmo.fill(template, fields))
>>
>> (wanted "function foo_new", got "function $name_new")
>>
>> I understand that cosmo cannot distinguish the possibility of a key
>> 'name_new' in the fields table, but I thought perhaps there was a way to
>> explicitly delimit the key in the template itself. E.g.:
>>
>> local template = "function $[name]_new"
>>
>> Or something like that. If not, then maybe this could be a feature
>> suggestion?
>
> Cosmo's development tree (available from LuaRocks repository
> http://luarocks.org/repositories/rocks-cvs has the $(name)_new syntax.
> The syntax is actually $(<exp>), where <exp> is a Lua expression
> (minus functions) evaluated in the current environment.
>
> You can see a log of commits at http://github.com/mascarenhas/cosmo.
>
>> Thanks!
>>
>
> --
> Fabio Mascarenhas
>