[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question about cosmo
- From: Fabio Mascarenhas <mascarenhas@...>
- Date: Mon, 18 Jan 2010 22:11:25 -0200
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