RXML: <ruby:put expr="1+2"/>


#1

Hello
railers,

I’ve always been annoyed by the fact that ERB doesn’t respect XML
specs.
As I mostly write XHTML, I’m trying to write a renderer using only
valid
XML files. Here is an example of a file so you get the feeling of
what
it’s going to
do:

<?xml version="1.0" encoding="utf-8"? > '1 + 2 = ' + (1 + 2).to_s

title It's still in the early development stage and I would like advice on the implementation and the various ruby/rails XML element that could/ should be implemented. It uses REXML to parse the file. For each node encountered, a method is defined which will be called at render time to render the node. At render time, a copy of the parsed tree is created, using the output of the previously defined methods. For now, I have a put, attr and eval tag. I'm not satisfied with the eval + block implementation and syntax: The syntax doesn't quite feel alright. If anyone has suggestion, they are welcome. Also in the implementation, I cannot evaluate the expressions in a clean binding because of the need to have a reference to the render_node method. It goes like: Kernel.eval(%Q[ #{node['expr']} do | #{node['args]}| render_node(current_node, parent_node, binding) end ]) If somebody is interested and is willing to review my code, I would be very happy to hear their thought/ advice/... The code is available at http://www.cosinux.org/~dam/rxml.tar.gz Best regards, -- Damien MERENNE http://blog.cosinux.org/


#2

Sorry for the formating. Google did not accept sending the mail from
my mutt client. Here is a hopefully better formatted version.

On 31 juil, 16:58, Canatella removed_email_address@domain.invalid wrote:
Hello railers,

I’ve always been annoyed by the fact that ERB doesn’t respect XML
specs. As I mostly write XHTML, I’m trying to write a renderer using
only valid XML files. Here is an example of a file so you get the
feeling of what it’s going to do:

<?xml version="1.0" encoding="utf-8"?> '1 + 2 = ' + (1 + 2).to_s

title

It’s still in the early development stage and I would like advice on
the implementation and the various ruby/rails XML element that could/
should be implemented.

It uses REXML to parse the file. For each node encountered, a method
is defined which will be called at render time to render the node. At
render time, a copy of the parsed tree is created, using the output of
the previously defined methods.

For now, I have a put, attr and eval tag. I’m not satisfied with the
eval + block implementation and syntax:

The syntax doesn’t quite feel alright. If anyone has suggestion, they
are welcome.

Also in the implementation, I cannot evaluate the expressions in a
clean binding because of the need to have a reference to the
render_node method. It goes like:

Kernel.eval(%Q[
#{node[‘expr’]} do |#{node['args]}|
render_node(current_node, parent_node, binding)
end
])

If somebody is interested and is willing to review my code, I would be
very happy to hear their thought/advice/…

The code is available athttp://www.cosinux.org/~dam/rxml.tar.gz

Best regards,


Damien MERENNE
removed_email_address@domain.invalid
http://blog.cosinux.org/