<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#66ffff">
On 05/04/12 15:59, Andrew Stewart wrote:
<blockquote
cite="mid:1C1171C9-4378-4B9D-A506-922389AF618C@airbladesoftware.com"
type="cite">
<pre wrap="">
On 4 Apr 2012, at 23:58, mudge wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Perhaps if we could
simplify the view part to simply be:
1. Take some state;
2. Return a string.
Then views and helpers would be practically the same thing and we
could tackle some of these problems more easily.
</pre>
</blockquote>
<pre wrap="">
I think Mustache goes some way towards this:
<a class="moz-txt-link-freetext" href="https://github.com/defunkt/mustache">https://github.com/defunkt/mustache</a>
</pre>
</blockquote>
Interesting. btw. I think I try to do something similar using what,
we already got in Rails like erb templates and by adding simple
Widget (View) class.<br>
My goal is to be able to see structure of the page directly in the
ruby code like this:<br>
<br>
def build_page<br>
nav_bar = Widget.new("navigation_bar") do |nav_bar|<br>
nav_bar << Container.new(:menu) do |menu|<br>
menu << Widget.new("link", :label=> "Product list",
:target => "/products")<br>
menu << Widget.new("link", :label=> "About",
:target => "/about")<br>
end<br>
nav_bar << Widget.new("search_field")<br>
end<br>
<br>
column_left = Container.new(:column_left) do |column_grid|<br>
column_grid << ProductView.new(@product) if @product<br>
column_grid << ProductListView.new(@products) if
@products<br>
column_grid << Container.new('picture_row') do
|picture_row|<br>
picture_row << Widget.new("sample_picture")<br>
picture_row << Widget.new("sample_picture")<br>
picture_row << Widget.new("sample_picture")<br>
end<br>
end<br>
<br>
column_right = Container.new(:column_right) do |column_grid|<br>
column_grid << Widget.new("sample_picture")<br>
column_grid << Widget.new("sample_picture")<br>
column_grid << Widget.new("sample_picture")<br>
end<br>
<br>
row_container = Container.new(:row_container) do |row_container|<br>
row_container << column_left<br>
row_container << column_right<br>
end<br>
<br>
@page = ::WebPage.build do |p|<br>
p << nav_bar<br>
p << row_container<br>
p << Container.new(:footer)<br>
end<br>
end<br>
<br>
Then I can call @page.render to generate page. I still use html.erb
templates to render single widgets.<br>
So this extra layer is mostly as a design plan for programmer.<br>
<br>
Example that use bootstrap is here: <br>
<a class="moz-txt-link-freetext" href="https://github.com/arekt/rendering_view">https://github.com/arekt/rendering_view</a> <br>
<br>
Everything is in very early stage, but example works, so it could be
useful for someone.<br>
<br>
cheers,<br>
Arek Turlewicz<br>
</body>
</html>