Rendering DTML from string
Hello all, I'm reading in text from a file residing in a LocalFS object, it contains DTML code. My DTML method prints the DTML code rather than rendering the variables. How can I get it to change this behaviour? IE --- In a folder I have 3 object - a_dtml b_html c_LocalFS-- | -- x.txt File contents - b_html ------ <h2>This should display as title text</h2> x.txt ----- <dtml-var name="b_html"> I need a_dtml to display - <h2>This should display as title text</h2> instead I get - <dtml-var name="b_html"> I've tried <dtml-var "_.getattr(c_LocalFS, 'x.txt')"> and a number of other variations on the same (getitem, etc. ) but can's seem to get this to work. What do I need to do to get a DTML method to render a string containing dtml code? Thanks. Samir
From: "Samir Mishra" <SamirMishra@cbuae.gov.ae>
I'm reading in text from a file residing in a LocalFS object, it contains DTML code. My DTML method prints the DTML code rather than rendering the variables. How can I get it to change this behaviour?
Try something like (untested): <dtml-let routine="_.getattr(c_LocalFS, 'x.txt')"> <dtml-var "_[routine]"> </dtml-let> HTH Jonathan
Doesn't work <dtml-var "_[someDTMLstrObj]">. I get the raw dtml in page source. Which doesn't display in the browser because browser doesn't understand DTML tags. Johnathan, you helped me out with a similar question some time ago. Thanks again. Any other suggestions? Samir. Small Business Services wrote:
From: "Samir Mishra" <SamirMishra@cbuae.gov.ae>
I'm reading in text from a file residing in a LocalFS object, it contains DTML code. My DTML method prints the DTML code rather than rendering the variables. How can I get it to change this behaviour?
Try something like (untested):
<dtml-let routine="_.getattr(c_LocalFS, 'x.txt')"> <dtml-var "_[routine]"> </dtml-let>
HTH
Jonathan
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
From: "DaMann" <hammerhead@linuxmail.org>
Doesn't work <dtml-var "_[someDTMLstrObj]">. I get the raw dtml in page source. Which doesn't display in the browser because browser doesn't understand DTML tags.
I am not familiar with the object you have stored in local file storage, but if you have the name of a dtml method stored in a variable (ie. variable routine contains 'x', where 'x' is the name of a dtml method) then you can execute that method via: <dtml-var "_[routine]"> If you have a text file containg dtml code and you want to execute that code, the only thing i can think of is to place that code into a dtml method and then execute the method, as follows: <dtml-call "REQUEST.set('routine', 'tst')"> <dtml-call "REQUEST.set('dtmlcode', '<dtml-var standard_html_header><dtml-var REQUEST><dtml-var standard_html_footer>')"> <dtml-comment> create the new method </dtml-comment> <dtml-call "manage_addDTMLMethod(routine, 'atitle')"> <dtml-comment> now put some content into the new dtml method </dtml-comment> <dtml-call "_.getitem(routine).manage_edit(dtmlcode, 'anewtitle2')"> <dtml-comment> now execute the new method </dtml-comment> <dtml-var "_[routine]"> To make this work with a text file containing dtml code, just replace the REQUEST.set('dtmlcode'... with the code to read your text file and store the contents in 'dtmlcode'. HTH Jonathan
participants (3)
-
DaMann -
Samir Mishra -
Small Business Services