retrogradeorbit / bootleg

Simple template processing command line tool to help build static websites
Eclipse Public License 2.0
254 stars 12 forks source link

Generating XML preserving the tag name case #62

Closed gleisonsilva closed 4 years ago

gleisonsilva commented 4 years ago

Hello, guys! May you can help me... I'm trying to use Bootleg 's (selmer ...) fn to generate some XML files where I need to replace some variables... I have a XML template file and it working, except for this: Selmer is changing all tag names to lower-case... (a tag "<Dimension ...>" has been replaced by "<dimension ...>") but I need to preserve the case. Do you know if thats is possible? How can I do?

retrogradeorbit commented 4 years ago

It probably is not selmer per-se, but the code coverting selmer to hiccup (which is using html processing libraries):

If I do:

$ bootleg -d -e '(selmer "<Foo>{{foo}}</Foo>" {:foo "bar"} :data)'
([:foo "bar"])

it becomes lower case. but that is being processed automatically into hiccup (and then with no -d flag to bootleg, back into html)

Getting selmer to return just the data:

$ bootleg -d -e '(selmer "<Foo>{{foo}}</Foo>" {:foo "bar"} :data :html)'
"<Foo>bar</Foo>"

case is preserved.

There is a (convert-to data :xml) that outputs xml and preserves case from mixed case hiccup:

$ bootleg -e '(-> [:Foo "bar"] (convert-to :xml))'
<?xml version="1.0" encoding="UTF-8"?><Foo>bar</Foo>

But there is a reflection error in the graal build preventing the the conversion of XML template to mixed case hiccup!

If you do not need to go through the hiccup stage at all, then you can just append :html to the selmer clause to prevent the autoconversion and preserve the case.

I will open a ticket for the case of converting to hiccup and preserving case.

gleisonsilva commented 4 years ago

Tks, @retrogradeorbit! The ":html" thing does the trick and it is enough for what I need right now.

retrogradeorbit commented 4 years ago

Fixed in v0.1.8