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
<dmere...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:rails="http://www.cosinux.org/rails"
xmlns:ruby="http://www.cosinux.org/ruby">
<body>
<ruby:put expr="''1 + 2 = '' + (1 +
2).to_s"/>
<ruby:put> ''1 + 2 = '' + (1 +
2).to_s</ruby:put>
<ruby:eval expr="(0..3).to_a.each" args="i">
<div id="foo_">
<ruby:attr name="id" expr="i"/>
<h1 rails:id="''foo''">title
<ruby:put expr="i"/></h1>
</div>
</ruby:eval>
</body>
</html>
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:
<eval expr="[1,2,3].each" args="i">
<put expr="i">
</eval>
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
<d...-xqxBqOIvj5dAfugRpC6u6w@public.gmane.org>
http://blog.cosinux.org/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---