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.

Vince /. <totalharmonicdistortion 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…

Wilson B. 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

On 10/17/06, Vince /. [email protected] wrote:

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?

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/18/06, [email protected] [email protected] wrote:

 <?r end ?>
<?r end ?>

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

  • this will be replaced with actual title

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

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

On 10/18/06, Jeff B. [email protected] wrote:

   </div>
 <?r end ?>
<?r end ?>

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

  • this will be replaced with actual title

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

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:

@nav_name @fundsym @nav.price @nav.change_price Check YTD

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| ?>
#{todolist.title}
<?r todolist.items.each do |item| ?>
#{item.title}
#{item.text}
<?r end ?>
<?r end ?>

Kirk H.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs