Code behind HTML

Hi,

After having some issues with eRuby and embedded ruby in HTML, Im trying
to find out if its possible to develop a web page in the same way that
ASP.NET works.

Basically you straight HTML with no embedded script and when all the
data is posted back to the server, you can use c# (or any language) to
handle and process the data returned.

I think CGI is different to what im after. Im looking at doing all my
processing in ruby and keeping my html 'clean'

Can someone point me in the right direction?

Thank you,
Vince

P.S
Im not interested in Rails.

···

--
Posted via http://www.ruby-forum.com/.

Vince /. <totalharmonicdistortion <at> hotmail.com> writes:

Hi,

Hi,

After having some issues with eRuby and embedded ruby in HTML, Im trying
to find out if its possible to develop a web page in the same way that
ASP.NET works.

Basically you straight HTML with no embedded script and when all the
data is posted back to the server, you can use c# (or any language) to
handle and process the data returned.

How does ASP.NET give users feedback (i.e. generate error messages and other
dynamic content?) It seems to me that HTML must be programmatically generated
somewhere along the way...

Vince /. wrote:

Hi,

Hi.

Can someone point me in the right direction?

Probably not the right direction, but worth a stroll:

  http://code.whytheluckystiff.net/camping

Later,

···

--
Bil Kleb
http://fun3d.larc.nasa.gov

What you've described isn't actually how ASP.NET works, but I can
understand what you're looking for.
I would say that 'Merb' is probably as close as it gets for Ruby
webapps right now:
http://brainspl.at/articles/2006/10/09/introducing-the-merb

Alternatively (or in addition to Merb), you could go with a templating
solution such as Liquid, instead of ERb. That way there's no direct
'Ruby' code mixed into your HTML. Some people like it that way.

···

On 10/17/06, Vince /. <totalharmonicdistortion@hotmail.com> wrote:

Hi,

After having some issues with eRuby and embedded ruby in HTML, Im trying
to find out if its possible to develop a web page in the same way that
ASP.NET works.

Basically you straight HTML with no embedded script and when all the
data is posted back to the server, you can use c# (or any language) to
handle and process the data returned.

I think CGI is different to what im after. Im looking at doing all my
processing in ruby and keeping my html 'clean'

Can someone point me in the right direction?

Probably, but it is a little hard to figure out just what direction is actually the right one for you.

My assumption is that you don't want to embed code right inside your HTML, like erb does with Ruby, or like the traditional PHP development style.

Rather, you want to write straight HTML. Have your forms forms, links, or whatever trigger Ruby code execution which handles the data submitted, and then either returns dynamically generated HTML or redirects to another static page?

I think, to varying extents, you can some some or all of the above with any of (in alphabetical order), Camping, IOWA, or Nitro.

Camping makes use of a nice little Ruby DSL called markaby to let you write Ruby code that looks like the HTML that it generates. From the camping web site: (http://code.whytheluckystiff.net/camping\)

      p 'Hi my name is Charles.'
      p 'Here are some links:'
      ul do
       li { a 'Google', :href => 'http://google.com' }
       li { a 'A sample page', :href => '/sample' }
      end

There is a community of people to help with it on freenode, at #camping.

IOWA is my framework. I went and ripped up its internals in interesting ways over the last few months, but it's mostly stable again. I released 0.99.2.17 -- It's Mostly Stable Again! -- today on Rubyforge (http://rubyforge.org/frs/?group_id=198\). The codebase is now running a new production web site, so I feel it's pretty darn close to stable again.

It uses a templating system that does not permit directly intermingling Ruby with HTML. Instead, it offers a very small set of special purpose tags to facilitate looping and conditional content, combined with the ability to embed the output of Ruby methods into the generated content. The combination is easy to learn to use but keeps the templates looking like clean HTML. http://enigo.com/projects/iowa for some old docs that are still pretty much accurate when it comes to the templating. See the /examples/hello_world/iowa dir for a simple sample app. I'm usually on #iowa on freenode, too, if you have questions.

A snippet of an IOWA template:

<table id="DailyNav">
   <repeat oid="nav data" list="navs" item="nav">
   <tr class="@rowclass">
     <td class="left">
       @nav_name
     </td>
     <td>
       @fundsym
     </td>
     <td>
       @nav.price
     </td>
     <td>
       @nav.change_price
     </td>
     <td>
       <a href="/performance.html">Check YTD</a>
     </td>
  </tr></repeat>
</table>

Nitro is a framework that uses an xhtml oriented templating system. It is a capable, performant framework, too. Nitro does allow you to embed code in with the HTML, but also offers a way to do render HTML content from within Ruby code. There are always folks on freenode at #nitro who are happy to answer Nitro questions.

A snippet of a Nitro template;

<?r @todolists.each do |todolist| ?>
   <div class="todolist">
   <div class="todolist_title">#{todolist.title}</div>
     <?r todolist.items.each do |item| ?>
       <div class="todolist_item">
         <div class="todolist_item_title">#{item.title}</div>
         <div class="todolist_item_text">#{item.text}</div>
       </div>
     <?r end ?>
   </div>
<?r end ?>

Kirk Haines

···

On Tue, 17 Oct 2006, Vince /. wrote:

Hi,

After having some issues with eRuby and embedded ruby in HTML, Im trying
to find out if its possible to develop a web page in the same way that
ASP.NET works.

Basically you straight HTML with no embedded script and when all the
data is posted back to the server, you can use c# (or any language) to
handle and process the data returned.

I think CGI is different to what im after. Im looking at doing all my
processing in ruby and keeping my html 'clean'

Can someone point me in the right direction?

Wilson Bilkovich wrote:

... you could go with a templating solution such as Liquid, instead of ERb. That way
there's no direct 'Ruby' code mixed into your HTML.

Or with a templating solution such as:

http://amrita2.rubyforge.org

···

--
Posted via http://www.ruby-forum.com/\.

Similarly, MasterView another template library which keeps the code
out of the html, the code would look like this.

<ul block="@todolists.each do |todolist|">
   <li content="todolist.title">this will be replaced with actual title</li>
</ul>

MasterView has been primarily designed to work with Rails having
directives that utilize rails helpers, however it can also be used
with standard Ruby ERB if you forgo the Rails based directives.

The project is in Rubyforge and other documentation/videos are available at
http://masterview.org/

If you have any questions just shoot me an email.

Jeff

···

On 10/18/06, khaines@enigo.com <khaines@enigo.com> wrote:

A snippet of a Nitro template;

<?r @todolists.each do |todolist| ?>
   <div class="todolist">
   <div class="todolist_title">#{todolist.title}</div>
     <?r todolist.items.each do |item| ?>
       <div class="todolist_item">
         <div class="todolist_item_title">#{item.title}</div>
         <div class="todolist_item_text">#{item.text}</div>
       </div>
     <?r end ?>
   </div>
<?r end ?>

oops. Forgot the namespace for the attributes should be prefixed with
mv: I have corrected it inline below.

> A snippet of a Nitro template;
>
> <?r @todolists.each do |todolist| ?>
> <div class="todolist">
> <div class="todolist_title">#{todolist.title}</div>
> <?r todolist.items.each do |item| ?>
> <div class="todolist_item">
> <div class="todolist_item_title">#{item.title}</div>
> <div class="todolist_item_text">#{item.text}</div>
> </div>
> <?r end ?>
> </div>
> <?r end ?>
>

Similarly, MasterView another template library which keeps the code
out of the html, the code would look like this.

<ul mv:block="@todolists.each do |todolist|">
    <li mv:content="todolist.title">this will be replaced with actual title</li>
</ul>

···

On 10/18/06, Jeff Barczewski <jeff.barczewski@gmail.com> wrote:

On 10/18/06, khaines@enigo.com <khaines@enigo.com> wrote:

MasterView has been primarily designed to work with Rails having
directives that utilize rails helpers, however it can also be used
with standard Ruby ERB if you forgo the Rails based directives.

The project is in Rubyforge and other documentation/videos are available at
http://masterview.org/

If you have any questions just shoot me an email.

Jeff