Code Monkey home page Code Monkey logo

Comments (4)

nguyenquangminh0711 avatar nguyenquangminh0711 commented on May 27, 2024

Hi @scottbarrow, thanks for your reporting. I have just tested in my local environment (Ruby 2.6.5, and 2.7.1 on Rails 6.0). It works quite well.

Screenshot from 2020-09-14 11-26-42

Could you give me some more information, such as your Ruby version, your Rails version, the environment you are running on (mac, linux?). If it's possible, could you try with a simple view, or empty view?

from ruby_jard.

nguyenquangminh0711 avatar nguyenquangminh0711 commented on May 27, 2024

Ahhhhh. I can now re-produce the bug now. So, if you put something like <%= jard %>, Jard won't stop at the file, while it works well with <% jard %>. It's an interesting bug, happens with byebug as well. I'll go dive deep to see what happens.

In the mean time, you could use <% jard %> instead.

from ruby_jard.

nguyenquangminh0711 avatar nguyenquangminh0711 commented on May 27, 2024

A debug story: as mentioned above, jard doesn't work with <%= jard %>, while still working with <% jard %>. Internally, ERB compiles the view template into a series of Ruby print statements, then evaluate all the statement with an input binding. This is a test file to point the differences between two approaches:

require 'erb'

str1 = <<-CODE
  <h1>
    <% jard %>
    <% a = 1 %>
  </h1>
CODE

puts ERB::Compiler.new(0).compile(str1).first.to_s
puts "==================="

str2 = <<-CODE
  <h2>
    <%= jard %>
    <% a = 1 %>
  </h2>
CODE
puts ERB::Compiler.new(0).compile(str2).first.to_s

Results:

#coding:UTF-8
print "  <h1>\n    ".freeze
;  jard ; print "\n    ".freeze
;  a = 1 ; print "\n  </h1>\n".freeze

===================
#coding:UTF-8
print "  <h2>\n    ".freeze
; print(( jard ).to_s); print "\n    ".freeze
;  a = 1 ; print "\n  </h2>\n".freeze

So, in the second script, jard is called as an an argument of print method call. Unfortunately, this case is not handled in latest version. This bug is fixed in #37.

from ruby_jard.

scottbarrow avatar scottbarrow commented on May 27, 2024

Awesome thanks

from ruby_jard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.