FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

kwargs in template tag {% lucidTag ... %}

 
Post new topic   Reply to topic    PyLucid - CMS - Forum Forum Index -> system
View previous topic :: View next topic  
Author Message
jens
Administrator


Joined: 12 Oct 2005
Posts: 972
Location: duisburg, germany

PostPosted: Mon 02 Jun, 2008 09:54    Post subject: kwargs in template tag {% lucidTag ... %} Reply with quote

The current implementation used regex for parsing the lucidTag kwargs:
Code:
KWARGS_REGEX = re.compile('''(\w*?)\=['"](.*?)['"]''')

see: http://trac.pylucid.net/browser/trunk/pylucid/PyLucid/template_addons/lucidTag.py?rev=1612#L32

The biggest problem is: We can't pass other thing than normal strings Sad I add some unittest for this problem: http://trac.pylucid.net/changeset/1615#file1 (at the bottom)

I add a ticked for this: http://trac.pylucid.net/ticket/202

I thought we can use data_eval.py for parsing. But the format of a tag is not realy good for it. Example:
Code:
{% lucidTag unittest_plugin arg1="test1" arg2=3 arg3=True arg4="Foo Bar" %}

We can use data_eval if its looks like a dict:
Code:
{ "arg1":"test1" "arg2":3 "arg3":True "arg4":"Foo Bar" }


Converting the string from above to a dict one is not easy. I tried it here: http://trac.pylucid.net/changeset/1615#file0 (The commented parts)

Solutions:

We can change the syntax of the lucidTag to a dict like syntax, e.g.:
Code:
{% lucidTag unittest_plugin "arg1":"test1" "arg2":3 "arg3":True "arg4":"Foo Bar" %}

Than we can easy extract the kwargs and evaluate it with data_eval.
On the other side, these syntax is a little more complex, isn't it?

Any feedback?
_________________

http://www.jensdiemer.de | http://www.htfx.de | http://www.python-forum.de
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PyLucid - CMS - Forum Forum Index -> system All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

<< back to PyLucid CMS Homepage



Powered by phpBB © 2001, 2005 phpBB Group