Hello,
I have a funny idea about using dry-view as SOAP templates renderer. I’m playing now with Tilt and I’ve been thinking about creating something like that(oh, yeah, I’m not using WSDL cause our industry does not respect them and they are usually out of date):
So, I have a few templates like that:
soap_layout.xml.erb
registration.xml.erb
passenger.xml.erb
And I need to render them like this:
soap_layout.xml.erb
<body>
<%=render_partial(registration, with: registration)%>
</body>
registration.xml.erb
<passengers>
registration.passengers.each do |p|
<%=render_partial(passenger, p)%>
end
</passengers>
passenger.xml.erb
<passenger>
<name><%=p.name%></name>
<surname><%=p.surname%></surname>
</passenger>
Well, it’s simplified version, there are tons of namespaces inside and so on.
The thing I wanna do is to precompile this template(merge this three partials into one xml, cut comments out of it, compress, process erb
) and cache in memory(we are sending and rendering a tons of this docs over the net). I’ve been considering to write partial engine by hand and for caching I’ve been considering to just use Tilt::Cache. I hope this cache will help us to increase speed of our app.
Right now we have something like this:
<body>
<1000_lines_of_mixed_ruby_and_xml_code>
unreadable_mess...
</1000_lines_of_mixed_ruby_and_xml_code>
</body>
To decrease time we are caching file like this:
temp = File.read(Rails.root.join("templates/#{@section}/#{@name}.xml.erb")).chomp.html_safe
GlobalCache["#{@section+@name}"] = temp
But this template is not precompiled and I believe we can gain a bit more out of cache.
The question is - can dry-view help me with this somehow, perhaps it has any caching facilities which are planned? Or you can give any advise or just criticise my idea
P.S. I’m looking for Rails-free solution