Helma 2 Templates - hannesSpec
Parsed skins are exposed as JavaScript arrays, with the static skin parts represented by string elements, while the macro parts are represented by a MacroTag class. The MacroTag class is itself a JavaScript array, with an additional params property to expose the named parameters. Consider for example the following skin source:
It is parsed to the following construct:
and the following conditions would evaluate to true:
ImplementationNative template scanning support is implemented in class org.helma.template.TemplateScanner, which can be conveniently accessed using the global parseSkin(str) and parseSkinResource(path) functions. It parses skins to a java.util.List filled with Strings for the static parts and Macro tags, which are again java.util.List objects with a special param property that contains the tag's named parameters. All this is wrapped in ScriptableLists and ScriptableMaps so you can sweep through it like it were native JavaScript arrays and objects. I started a simple JavaScript renderer for skins parsed this way. It currently implements very simplistic if/foreach constructs.
The following code shows how to use this:
TodoWhat probably remains to be done is add smarts to the parsing of parenthesised expressions such as "(foo in bar)" or "(x < y)". Currently, these are simply parsed to a separate list/array. We might use a special purpose class for this that gives some support in determining what kind of expression we're dealing with. ExamplesI removed the old examples since they didn't match the renewed spec anymore. Generally speaking, all kinds of macro syntax can be implemented based on the features discribed in this proposals, as long as they use <% %> as macro delimiters. CommentsI removed Jürg's comments as well, for the same reason. Pages linking to this page: Helma 2 Templates |
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Helma NG Wiki
Wiki
Tags
Updates
Related Projects
Sites using Helma
Shop
search
tags for this page
all tags
Tagsapps (1) bugs (2) class (1) community (2) compatibility (1) concurrency (1) continuations (2) Documentation (6) dogfood (1) formatting (1) functions (1) gobi (1) helma (7) helma 1.6 (13) helma 1.7 (8) helma 1.x (1) helma 2 (11) helma ng (20) hopobject (1) howto sample code xml-rpc (1) html (1) inheritance (5) introspection (1) java (3) javascript (5) jetty (1) JSDoc (1) lazy (1) marius person (1) metaprogramming (3) modules (5) oop (1) organization (2) ORM (2) parsing (1) plugins (1) project (2) projects (1) prototype (2) prototype scope rhino functions this (0) Rabbit (2) Reference (1) REPL (1) rhino (5) roadmap (3) scope (1) shell (1) shop (0) Skin Rendering (5) Snippets (1) source svn (1) sugar (3) templates (13) testing (5) this (1) Tobi (7) xml (1) Pages linking to this page: Wiki Overview Text Draft, wiki pages linking here
|