Erb syntax - unknown syntax

Hi, I am a very beginner on Ruby and related stuff, Could you please
tell me
what a tag like this "<%!" means in the following code. Also, I would
really appreciate if you can give me some ref to erb templates.

<%! if filmstrip_image_path.blank? %>

Also what does this '?' do in the above code

Thanks,
Georgy

···

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

Hi, I am a very beginner on Ruby and related stuff, Could you please
tell me
what a tag like this "<%!" means in the following code. Also, I would
really appreciate if you can give me some ref to erb templates.

The official documentation can be found here:

or use `ri ERB' in the command line.

<%! if filmstrip_image_path.blank? %>

Also what does this '?' do in the above code

It's just part of the method name `blank?'.
By convention, methods with a name ending with
a question mark return a boolean value, false or true.

···

Am 30.10.2012 05:59, schrieb Georgy Daniel:

--
<https://github.com/stomar/&gt;

okay what about the '!' in <%! if filmstrip_image_path.blank? %>

unknown wrote in post #1081937:

···

Am 30.10.2012 05:59, schrieb Georgy Daniel:

Hi, I am a very beginner on Ruby and related stuff, Could you please
tell me
what a tag like this "<%!" means in the following code. Also, I would
really appreciate if you can give me some ref to erb templates.

The official documentation can be found here:
Class: ERB (Ruby 1.9.3)

or use `ri ERB' in the command line.

<%! if filmstrip_image_path.blank? %>

Also what does this '?' do in the above code

It's just part of the method name `blank?'.
By convention, methods with a name ending with
a question mark return a boolean value, false or true.

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

Sorry, no clue. It doesn't seem to be a part of erb.

I guess it should be parsed as a boolean `not'.
But to see whether that makes sense here, you would have
to provide more of the surrounding code, especially the
rest of the if statement.

···

Am 30.10.2012 10:33, schrieb Georgy Daniel:

okay what about the '!' in <%! if filmstrip_image_path.blank? %>

--
<https://github.com/stomar/&gt;

I don't think it is associated with the if condition, here there is
another instance of the '!'

<%!
   require 'cgi'
  require 'json'
        .....................
        .....................
%>

Also here is the if condition block

<%! if filmstrip_image_path.blank? %>
   <div id="main-page">
      <img src="resources/image.jpg" alt="My Image"></img>
      <img id="main-page-text" src="resources/image.png"></img>
   </div>
<%! end %>

unknown wrote in post #1081950:

···

Am 30.10.2012 10:33, schrieb Georgy Daniel:

okay what about the '!' in <%! if filmstrip_image_path.blank? %>

Sorry, no clue. It doesn't seem to be a part of erb.

I guess it should be parsed as a boolean `not'.
But to see whether that makes sense here, you would have
to provide more of the surrounding code, especially the
rest of the if statement.

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

And this code works? Are you really using the standard erb?
For me (ruby 1.9.3p194), the following template gives a syntax error

<%! if true %>
   true
<%! end %>

Because this is interpreted as

   ! if true
     ...
   ! end

where the first '!' is possible but completely useless here,
and the second '!' is syntactically wrong.

The fact that <%! has no special meaning but is treated
like <% and the boolean `!' can be seen here:

   require 'erb'
   template = <<EOF
   <%! false && (text = 'true!!!') %>
   <%= text %>
   EOF
   puts ERB.new(template).result

outputs `true!!!', because the ruby code is taken to be

   !false && (text = 'true!!!')

and the assignment of `true!!!' to the variable takes place.
The same with <%! true && ... %> gives no output, as expected.

···

Am 30.10.2012 13:10, schrieb Georgy Daniel:

I don't think it is associated with the if condition, here there is
another instance of the '!'

<%!
    require 'cgi'
   require 'json'
         .....................
%>

Also here is the if condition block

<%! if filmstrip_image_path.blank? %>
    <div id="main-page">
       <img src="resources/image.jpg" alt="My Image"></img>
       <img id="main-page-text" src="resources/image.png"></img>
    </div>
<%! end %>

--
<https://github.com/stomar/&gt;

Thanks you, I really appreciate your help on this.

···

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