seattlerb/flay

Parse error

mockdeep opened this issue · 20 comments

I get the following error when running flay on my project:

app/views/docs/new.html.erb:17 :: parse error on value ")" (tRPAREN)
skipping app/views/docs/new.html.erb

The code it references is:

<%= f.hidden_field :font_size %>

Dunno if it has any relevance, but it's directly inside a form tag:

<%= form_for @doc, :html => {:multipart => true, :class => "form-horizontal"} do |f| %>

Unfortunately, it is going to be line 17 of the evaluated ERB. Can you provide me with the source of the file?

On Jul 5, 2013, at 13:26 , Robert Fletcher notifications@github.com wrote:

I get the following error when running flay on my project:

app/views/docs/new.html.erb:17 :: parse error on value ")" (tRPAREN)
skipping app/views/docs/new.html.erb

The code it references is:

<%= f.hidden_field :font_size %>

Dunno if it has any relevance, but it's directly inside a form tag:

<%= form_for @doc, :html => {:multipart => true, :class => "form-horizontal"} do |f| %>


Reply to this email directly or view it on GitHub.

Here is the source from the page. Line 17 of the file is the hidden field mentioned above.

<%
  @page_title = "Add document"
  @hub = nil
  @track = nil
  @archives = nil
  @show = nil
  @cancel = 'display_none'
  @tutorial = nil
  @back = 'display_none'
%>

<%= render 'shared/error_messages', :object => @doc %>

<div class="create_container">
  <div class="clear step_container showing">
    <%= form_for @doc, :html => {:multipart => true, :class => "form-horizontal"} do |f| %>
      <%= f.hidden_field :font_size %>
      <div class="control-group input-thing">
        <label class="control-label control-label-upload" for="input_box"><strong>Document Name</strong></label>
        <div class="controls">
          <%= f.text_field :title, :class => "input-csv", :placeholder => "e.g. 'Permission Slip'" %>
        </div>
      </div>

      <div class="alert alert-success alert-regular">
        <div class="csv_header_info">Upload a PDF or image.</div>
        <div class="control-group horizontal_divide">
          <label class="control-label control-label-upload" for="upload_box"><strong>Document</strong></label>
          <div class="controls">
            <div class="pretty_file_field" id="upload_box">
              <div class="btn btn-info ">Choose file</div>
              <%= f.file_field :pdf, :onchange => "check_file()" %>
              <span class="pretty_file_name">No file selected...</span>
            </div>
          </div>
        </div>
      </div>

      <div id="upload_area">
        <%= image_tag 'loader-big.gif' %>
        <span class ="small_badge">Uploading, please wait...</span>
      </div>

      <div class="buttons_form_2">
        <div class="fileupload-buttonbar">
          <%= link_to "Go back", {:action => :chalk_desktop}, :class => "btn btn-large", :id => "cancel_link" %>
          <%= submit_tag "Save Document", :class=>"btn btn-success btn-large button_create", :id => "save_doc" %>
        </div>
      </div>
    <% end %>
  </div>
</div>

<div class="modal hide fade">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
      &times;
    </button>
    <h3>File type not allowed</h3>
  </div>
  <div class="modal-body">
    <p class="fine-print">
      Please choose an <strong>image file or PDF</strong>
    </p>
  </div>
  <div class="modal-footer">
    <a href="#" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">
      Ok
    </a>
  </div>
</div>

Ah. I see it now. You shouldn't be using <%= on the form_for line. Instead, you should use <%.

P.S. I hate everything about your username. :P

That's true for Rails 2, but Rails 3 and up you use <%=. http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

While I've certainly had a number of people ask me about my username, you're the first to be offended by it. Is there a particular aspect of it that you find distasteful?

If you're using some other ERB implementation, flay is probably going to break on it. eRB is acting appropriately given its input (as I understand it).

I'm using the default implementation that comes with Rails 3. The page renders without a problem.

ERB ships with ruby. So it sounds like rails has a custom impl or at least hacks on it

On Jul 5, 2013, at 18:32, Robert Fletcher notifications@github.com wrote:

I'm using the default implementation that comes with Rails 3. The page renders without a problem.


Reply to this email directly or view it on GitHub.

@tenderlove says that he thinks rails uses erubis, not ERB. So this would need a new plugin for flay.

Interesting. So flay parses the templates with the ruby implementation of ERB? Is it getting hung up on blocks then?

Rails uses ERB with patched erubis engine (and patch is there explicitly to support blocks, like in form_for). Unfortunately flay plugin system is extension-based, so you cannot make a plugin for alternative erb parsing.

On Jul 8, 2013, at 16:40 , Eugene Kalenkovich notifications@github.com wrote:

Rails uses ERB with patched erubis engine (and patch is there explicitly to support blocks, like in form_for). Unfortunately flay plugin system is extension-based, so you cannot make a plugin for alternative erb parsing.

No, you can easily write a flay-erubis gem that, when installed, overrides the erb code that ships with flay.

This will depend on what order of files Gem.find_files("flay_*.rb") will give - process_erb from the last loaded will win.

On Jul 8, 2013, at 17:48 , Eugene Kalenkovich notifications@github.com wrote:

This will depend on what order of files Gem.find_files("flay_*.rb") will give - process_erb from last will win.

No, it doesn't. Add process_erb and put "erb" in @@plugins. The system is made to be flexible.

Thanks for clarification, modification of @@plugins was not really an obvious idea. I'll look at creating a plugin

Try to use
gem install flay-actionpack

Works without error for me, but now it's showing code duplication on the same lines for many of the views:

1) IDENTICAL code found in :attrasgn (mass*2 = 1404)
  ./app/views/docs/_doc_view.html.erb:8
  ./app/views/docs/_doc_view.html.erb:8

Try -d to see what code is about. Unfortunately erb compiled into ruby does not give a good line-to-line match.

When I do that it shows the same chunk of code twice, even though theirs nothing like it elsewhere. Of note, it appears to be doing this around the form_for blocks... Here are the first few lines of the output:

1) IDENTICAL code found in :attrasgn (mass*2 = 1404)
  A: ./views/docs/_doc_view.html.erb:8
  B: ./views/docs/_doc_view.html.erb:8

   @output_buffer.append = form_for(form_request, :url => (responses_path), :method => :post) do |f|
     @output_buffer.safe_concat("\n")
     @output_buffer.safe_concat("  <div class='view_container'>\n    ")
     @output_buffer.append = render("doc_hidden_fields", :f => (f))
     @output_buffer.safe_concat("\n")
     @output_buffer.safe_concat("    ")
     @output_buffer.append = render(@doc)
     @output_buffer.safe_concat("\n")

(potential) problem found, will release new version in couple minutes

Closing.