By default TG uses "kid" as its templating language. To change that go to wiki20/config/app.cfg
and search for
# tg.defaultview = "kid". copy it down and change to antlr_string.
tg.defaultview = "antlr_string"
Change the extension of all your templates to ".st"
start your server again and lo and behold, you have a welcome.st greeting you at the browser:).
=====
If you are feeling a little naughty, try this:
1. in the plugin make the extesion as ".kid" instead of ".st"
2. But change everything else to use antlr string template.
3. Now your kid templates are rendered by AST.
4. if you carefully chose py:replace and py:strip attributes, you can enclose your AST syntax in that.
5. Now when kid processes those templates, you dont see any of your AST code, when AST processes, you might see some jargon, but you can be careful and test on both engines and get good output :).
==
What you lose in this process is a strict enforcement of well formedness etc..
But what you gain is a clear line of separation between controller and view.
The only "disadvantage" if any is that the controller should know before hand what the keys used in the template are.
RamonTurboGears
Thursday, January 17, 2008
installing the plugin
now edit setup.py to look like the following.
then follow the standard python setup.py config, build and install --prefix .
After this step if you try tg-admin info at the command line, you should see something like the following in the output [ your versions may vary]:
Template Engines
* genshi-markup (Genshi 0.4.1)
* genshi-text (Genshi 0.4.1)
* genshi (Genshi 0.4.1)
* kid (TurboKid 1.0.1)
* cheetah (TurboCheetah 0.9.5)
* json (TurboJson 1.0)
* mako (Mako 0.1.6)
* antlr_string (RamBuffetString 0.1.1)
Now there is only one final step to start using ANTLR StringTemplate to create the view for your new website or wiki.
then follow the standard python setup.py config, build and install --prefix .
After this step if you try tg-admin info at the command line, you should see something like the following in the output [ your versions may vary]:
Template Engines
* genshi-markup (Genshi 0.4.1)
* genshi-text (Genshi 0.4.1)
* genshi (Genshi 0.4.1)
* kid (TurboKid 1.0.1)
* cheetah (TurboCheetah 0.9.5)
* json (TurboJson 1.0)
* mako (Mako 0.1.6)
* antlr_string (RamBuffetString 0.1.1)
Now there is only one final step to start using ANTLR StringTemplate to create the view for your new website or wiki.
Pasted as Python by ramontg [ Remove line numbers | Show as plain text | Create new paste ] |
Description: setup.py for antlrstringtemplate |
URL: http://rafb.net/p/3GEE1916.html |
1 | from setuptools import setup, find_packages |
Labels:
Plugin,
Python,
StringTemplate,
TurboGears
interfacing ANTLR StringTemplate and TurboGears
1. Follow previous post to install everything.
Download http://projects.dowski.com/files/buffetstring/BuffetString-0.1.1.zip
unzip and edit the file buffetstring/stringsupport.py to look like the following.
Then follow the next post to change setup.py
Download http://projects.dowski.com/files/buffetstring/BuffetString-0.1.1.zip
unzip and edit the file buffetstring/stringsupport.py to look like the following.
Then follow the next post to change setup.py
Pasted as Python by ramontg [ Remove line numbers | Show as plain text | Create new paste ] |
Description: Plugin to use ANTLR string template on turbogears. |
URL: http://rafb.net/p/ZmYxfJ83.html |
1 | """ |
Labels:
Buffet,
Plugin,
Python,
StringTemplate,
TurboGears
python version of stringtemplate
This post details how to install it so that you can write local python programs and process your own templates.
get the latest stringtemplate from stringtemplate.org . I have PyStringTemplate-3.1b1
make sure you note the dependencies properly.
the numbers on the left are from my history list. don't type those!!
1091 wget http://antlr2.org/download/antlr-2.7.7.tar.gz
1093 tar xzf antlr-2.7.7.tar.gz
1131 cd antlr-2.7.7/lib/python
1138 ls
1139 python setup.py config
1140 python setup.py build
1141 python setup.py install --prefix=/local/local/apps/python/
1142 p
1143 cd ../../../stringtemplate3-3.1b1/
1144 l
1145 python setup.py config
1146 python setup.py build
1147 python setup.py install --prefix=/local/local/apps/python/
Thats all there is to it. now you can try all the cool code on the stringtemplate.org site.
get the latest stringtemplate from stringtemplate.org . I have PyStringTemplate-3.1b1
make sure you note the dependencies properly.
the numbers on the left are from my history list. don't type those!!
1091 wget http://antlr2.org/download/antlr-2.7.7.tar.gz
1093 tar xzf antlr-2.7.7.tar.gz
1131 cd antlr-2.7.7/lib/python
1138 ls
1139 python setup.py config
1140 python setup.py build
1141 python setup.py install --prefix=/local/local/apps/python/
1142 p
1143 cd ../../../stringtemplate3-3.1b1/
1144 l
1145 python setup.py config
1146 python setup.py build
1147 python setup.py install --prefix=/local/local/apps/python/
Thats all there is to it. now you can try all the cool code on the stringtemplate.org site.
Subscribe to:
Posts (Atom)