lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



The current Cosmo has arguments for applications, so you can have those:

$include{ "html/shared/foo.lua.tpl" }, just define an include function in the template's environment

$set{ "foo", "whatever" }, again, define a set function, or even $foo{ "whatever" }, and patch the environment's __newindex to set foo.

$config|settings|foo|bar|baz will get env.config.settings.foo.bar.baz, where env is your template's environment. Again, you can make it shorter with something like $cfg|foo|bar|baz, by putting cfg in your environment as an alias to config.settings.

The syntax is different, but the capability is there, check http://cosmo.luaforge.net, and the code for Orbit pages. And you can always add your syntax as sugar by tweaking the LPEG grammar (mostly in LPEG's re language).

--
Fabio Mascarenhas

On Mon, Aug 18, 2008 at 1:37 PM, DarkGod <darkgod@t-o-m-e.net> wrote:
> Hi,
> Did you patch the old (gsub-based) Cosmo or the newer (LPEG-based) ones? If
> the former I think it's easier if you just tell what you did. :-)

The gsub-based one, and an old one of those as well :)

>From memory I changed it to allow:
- subtemplate inclusion in the form of a file like: $<<html/shared/foo.lua.tpl>>
- field definition from a template: $=:foo[[whatever]]
 Then $foo will spit out "whatever"
- direct inclusion of a config setting (see my config module
 http://lua.net-core.org/sputnik.lua?p=Telesto:About)
 Something like $##foo.bar.baz## which will look into
 "config.settings.foo.bar.baz"

Nothing too horrible but still necessary to me :)