Getting away from the old php code

Hello,

  How can i embed ruby code into a html page,
  like php code, without using erb, nor
  its IMO slightly ugly syntax? (I am
  using Apache2.)

  - Yes, I want to do this.

  Basically what I'd like to do is replace
  my old php scripts, which are in part
  embedded, in part just simple html
  generators. I figured that the
  stuff that has to be rewritten in ruby
  would be a lot easier to maintain and
  extend, than continuing with
  php (on webstuff). But I like to keep
  the "embedded" logic simple as it
  currently is. Ruby simply is
  a much better language than php.

  No, I dont need rails - i need a hammer
  for my nail, not a hovering tank to shoot
  down the whole building (read as:
  complexity). :slight_smile:

···

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

Marc Heiler wrote:

Hello,

  How can i embed ruby code into a html page,
  like php code, without using erb, nor
  its IMO slightly ugly syntax? (I am
  using Apache2.)

  - Yes, I want to do this.

  Basically what I'd like to do is replace
  my old php scripts, which are in part
  embedded, in part just simple html
  generators. I figured that the
  stuff that has to be rewritten in ruby
  would be a lot easier to maintain and
  extend, than continuing with
  php (on webstuff). But I like to keep
  the "embedded" logic simple as it
  currently is. Ruby simply is
  a much better language than php.

  No, I dont need rails - i need a hammer
  for my nail, not a hovering tank to shoot
  down the whole building (read as:
  complexity). :slight_smile:
  
Why not use erb (or eruby)? The syntax is pretty much the same as PHP, except with "<%" instead of "<?"
If you are really against it, though, you can google around for some other web templating tools. I know several exist, but I've always been fine with eruby.

-Justin

You can use any other template library, too,
Amrita2 for example.

···

On 2006.10.18 07:57, Marc Heiler wrote:

Hello,

  How can i embed ruby code into a html page,
  like php code, without using erb, nor
  its IMO slightly ugly syntax? (I am
  using Apache2.)

Marc Heiler wrote:

  How can i embed ruby code into a html page,
  like php code, without using erb, nor
  its IMO slightly ugly syntax? (I am
  using Apache2.)

What about ERB do you find offensive?

Or, put another way, what WOULD you like your HTML+Ruby to look like?

Here's a thread that's relevant, particular Harold Hausman's response:
http://rubyurl.com/gWw

I can attest to the simplicity of using Ruby Web (esp. along with
SQLite3 and Array Fields).

If you are familiar with PHPTAL which makes a standard static html
page into a dynamic one using an attribute language then you might
like MasterView which is a plugin for Rails which works similarly.

MasterView allows you to use the full power of rails partials,
layouts, helpers, etc while still keeping a WYSIWYG editable html
file. Any WYSIWYG changes that you apply to the html are used in the
final rendering (they are merged with the options in the attribute
directives.

MasterView is a Rubyforge project
http://rubyforge.org/projects/masterview

I also have a video and some screenshots here
http://masterview.org/

I'd be glad to answer any questions that you have.

Blessings,

Jeff

···

On 10/17/06, Marc Heiler <shevegen@linuxmail.org> wrote:

Hello,

  How can i embed ruby code into a html page,
  like php code, without using erb, nor
  its IMO slightly ugly syntax? (I am
  using Apache2.)

Phrogz wrote:

Here's a thread that's relevant, particular Harold Hausman's response:
http://rubyurl.com/gWw

...except that 2 of the 3 URLs used in that response are already dead.

Ruby-Web : http://rubyforge.org/projects/ruby-web/
SQLite3 : http://rubyforge.org/projects/sqlite-ruby/
ArrayFields : http://www.codeforpeople.com/lib/ruby/arrayfields/

Hi guys,

sorry for the delayed reply.

Thanks for the replies. I'll try to find out how the
<% is used by erb. There must be a way to patch it
to allow other delimiters, even if I am the only
one who will use that. :slight_smile:

···

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

Again, what is so bad about <% that makes PHP's <? so nice? You've never
given a reason that you don't want to use ERB.

Frankly, there are ERB shortcuts:

% for stuff in @stuffs
% end

Check out the ERB docs.

Jason

···

On 10/23/06, Marc Heiler <shevegen@linuxmail.org> wrote:

Hi guys,

sorry for the delayed reply.

Thanks for the replies. I'll try to find out how the
<% is used by erb. There must be a way to patch it
to allow other delimiters, even if I am the only
one who will use that. :slight_smile:

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

Is there any particular reason you do not want to use the
standard delimiter? This is how erb works:

  # Template
  <% math_result = 1 + 1%>
  Hello, I am a math genious. 1 + 1 = <%= math_result %>.

  # Result
  Hello, I am a math genious. 1 + 1 = 2

···

On 2006.10.24 03:21, Marc Heiler wrote:

Hi guys,

sorry for the delayed reply.

Thanks for the replies. I'll try to find out how the
<% is used by erb. There must be a way to patch it
to allow other delimiters, even if I am the only
one who will use that. :slight_smile:

If you really can't stand the <% syntax then download and install the erubis gem. It is an Erb clone that behaves the same way ecept it has many more features and is 3 times faster then Erb. It also allows you to set the template delimiters to whatever you want. So if you were totally off your rocker you could even do this:

<?php [:foo, :bar, :baz].each do |sym| ?>
   <?= sym ?>
<?php end ?>

:wink:

-- Ezra Zygmuntowicz-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)

···

On Oct 23, 2006, at 8:42 PM, Eero Saynatkari wrote:

On 2006.10.24 03:21, Marc Heiler wrote:

Hi guys,

sorry for the delayed reply.

Thanks for the replies. I'll try to find out how the
<% is used by erb. There must be a way to patch it
to allow other delimiters, even if I am the only
one who will use that. :slight_smile:

Is there any particular reason you do not want to use the
standard delimiter? This is how erb works:

  # Template
  <% math_result = 1 + 1%>
  Hello, I am a math genious. 1 + 1 = <%= math_result %>.

  # Result
  Hello, I am a math genious. 1 + 1 = 2

Hiyas again, and once again sorry for the delayed
reply. Reason I check not often is that I have
it on a long list of things to check regulary
after some time passes, and there are too many
places I have to keep track over time, forums, mailing
list and so on. :slight_smile:
Hope you dont mind, I *do* read it all though but
it may take some time.

Anyway now, since some want an answer, first I start with a quote:

  "Again, what is so bad about <% that makes PHP's <? so nice?
   You've never given a reason that you don't want to use ERB."

Please do not misquote me. I never made the notion that <? is
nice. I do not really like it, either. :slight_smile:
But I agree that I was not clear about it,
so the confusion is understandable.

I actually meant

   <?php

instead of
   <?

Thus I agree there is no real difference between using
<? or <%

Both look a bit like Snoopy starting to swear :wink:

Also, in my old php stuff, I do not really use the
<? shortcut for it. But I'd like to have exactly the
same way for erb.

Anyway to answer that question:
  * First, the % character reminds me of ASP Syntax.
  * Second, as I now hopefully made clear - sorry that I
    forgot that in my first comment - I am using the
    longer version
      <?php
  ALWAYS.

  * Third, I do not need it (php) to do line evaluation.
  For clarification I do NOT use PHP to do line
  evaluation such as the following:

    <? print("this is php and it wants a ; !"); ?>

  For me, using ruby such as in:

    <% puts "ruby is much better everywhere ;-)" %>

  or

    <= some_assignment=5 >

  I think it looks ugly in both cases, even though
  ruby code doing the same tasks will always look cleaner
  than php. :>

  I prefer the longer PHP notion simply because
  something such as:

    <?php

  seems less cryptic to me than:

    <%

  or also

    <?

  So in summary it is mostly a matter of personal taste.

  Hope that cleared up some things now :slight_smile:

  "Frankly, there are ERB shortcuts:

  % for stuff in @stuffs
  % end

  Check out the ERB docs."

  I will be happy as soon as I can use:

    <?ruby

  instead. :slight_smile:

   "If you really can't stand the <% syntax then download and install
   the erubis gem. It is an Erb clone that behaves the same way ecept
   it has many more features and is 3 times faster then Erb. It also
   allows you to set the template delimiters to whatever you want. So if
   you were totally off your rocker you could even do this:

   <?php [:foo, :bar, :baz].each do |sym| ?>
     <?= sym ?>
   <?php end ?>
   "

   WOOOOOOOOOT!
   It looks extremely ugly (i mean the <?= part)
   but the <?php thing looks very nice.

   Thanks a LOT for the link, I will have a good look
   at erubis. The <?php choosing alone seems nice enough
   to use erubis. At least it seems to be better than
   Erb when I read you correctly? Or is there a catch with
   it... anyway off to look at erubis now :slight_smile:

···

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