26 April 2007 - sgte 0.3.0
I have completed the parser rewrite of sgte.
The new version (0.3.0) is available for download on the google project page:
http://code.google.com/p/sgte/Changes
join of items
In the previous version a join template was written like this:
$join ", " columns$
In the new version the same template is written:
$join:{, } columns$The new syntax for join reflects the syntax used for the inline map.
map feature
Map has undergone the major changes. There was a bug in the management of multiple inline templates (thanks to tobbe for finding the bug and for his suggestions). I.e. when you had a template like:
$map:{
<li class="odd">$item$</li>,
<li class="even">$item$</li>} itemList$Where itemList was [{item, "Item1"}, {}item, "Item2", {item, "Item3"}]. You got:
<li class="odd">Item1</li>
<li class="even">Item2</li>
<li class="odd">Item3</li>
The problem was the templates separator "," if found both as a separator and as text to be rendered was parsed incorrectly. Moreover the use of the comma as a separator was really a bad choice since it can easily be found in javascript code and in normal text to render.
I've removed this feature for now.
I don't think anyone uses it at the moment. If someone needs it let me know and I'll put it back in place choosing a better separator.
The non inline map instead now can assume one of the following forms:
$map tmpl items$
$mmap tmpl1 tmpl2 tmpl3 items$
$mapl tmpl items$
The first one is the map of compiled template tmpl over a list of items as before.
If you have multiple templates you want to alternate (e.g. for even and odd rows in a table) you can use mmap.
Finally mapl is a small facility that can be usefull in some cases. I illustrate it with a small example:
{ok, Row} = sgte:compile("- $attr$").
{ok, MapTmpl} = sgte:compile("$map row names$").
sgte:render(MapTmpl, [{row, Row}, {names, ["foo", "bar", "baz"]}]).
Here names is a list of values instead of a list of {key,value} pairs. each name is passed to the row template using attr as key. names is converted during rendering to [{attr, "foo"}, {attr, "bar"}, {attr, "baz"}]. The result is:
- foo
- bar
- baz
Other changes
Other changes include:
- line numbers added in error messages
- better management of blanks in templates. Multiple spaces and newlines are properly handled inside template statements
- the make test now works
- code has been refactored in a parse module and a render module
Comments (0) -
Leave a Comment
20 April 2007 - sgte parser rewrite
After some testing and the first experiences using sgte I'm doing a complete rewrite of the parser.
The code in the first version after some changes was quickly becoming unmantainable, so I decided to rewrite it from scratch.
The interface and the language is mainly the same as the previous version. There are a couple of new features and some smaller incompatible changes I will document before merging the new version in the main trunk.
The rewrite can be found in the TRY-parser-rewrite branch on the project page on Google.
You can checkout the branch with the command:
svn checkout http://sgte.googlecode.com/svn/branches/TRY-parser-rewrite sgte
The rewrite is almost finished. I have to fix some bugs in the if templates, and write documentation for the new features.
The new version should be available in the next week.
Comments (0) -
Leave a Comment
19 April 2007 - Wedding-Siena.com
Wedding-Siena.com is a newly published website of
Filippo Galluzzi.
Filippo recently started his new adventure as a photographer.
So if you are planning a wedding in Tuscany, or if you are looking for great photos of Tuscany countryside, take a look at his websites and contact him.
He is a great photographer as well as a friend.
Comments (0) -
Leave a Comment