apotonick / erbse Goto Github PK
View Code? Open in Web Editor NEWNext-generation ERB.
License: MIT License
Next-generation ERB.
License: MIT License
<div class="class1 <%= 'class2' %> <%= 'class3' %>></div>
evaluates to
<div class="class1 class2class3"></div>
2.3.3 :001 > require 'erbse'
=> true
2.3.3 :002 > eval Erbse::Engine.new.call(%{<div class="class1 <%= 'class2' %> <%= 'class3' %>"></div>})
=> "<div class=\"class1 class2class3\"></div>"
2.3.3 :003 >
is this intended?
Hi, happy to found this nice gem today, but not sure if there is a category tag setup or something missing but this gem is not listed in the template-engine list on RubyToolbox. Is it an issue from the site or something that can be setup in the repo? Feel free to disregard this issue if the former.
I'm using Erbse outside the context of Cells. For me, it would make sense if Erbse could do the escaping by default. See Erbuis: https://github.com/rtomayko/tilt/blob/master/lib/tilt/erubis.rb#L22
How would you implement such a feature? Perhaps I can do this by myself.
BTW: The capturing feature is awesome. No other templating engine provides this.
what <%= 'ever' if true %>
evaluates to an empty string
> eval Erbse::Engine.new.call("what <%= 'ever' if false %>")
=> ""
> Erbse::Parser.new.call("what <%= 'ever' if true %>")
=> [:multi]
==========
<% [].each do %>
<% next if true %>
<% end %>
produces incorrect ruby syntax
> eval Erbse::Engine.new.call("<% [].each do %>\n<% next if true %>\n<% end %>")
SyntaxError: (eval):3: syntax error, unexpected keyword_end, expecting end-of-input
; end; _buf = _buf.join("".freeze)
^
from (irb):8:in `eval'
from (irb):8
from /home/roma/.rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'
> Erbse::Parser.new.call("<% [].each do %>\n<% next if true %>\n<% end %>")
=> [:multi, [:newline], [:block, " next if true ", [:multi, [:newline]]]]
Why have you forked Erubis? What's missing? What are the planned improvements?
Yes I know that logic in views is a code smell, but I have to work with legacy code. However...
While upgrading cells from 3.x to 4.1.7 I've come across a problem. A template with a massive case statement does not work. If I cut it back to the simplest possible case statement I still get this
NoMethodError:
undefined method `<<' for nil:NilClass
# Irrelevant_stuff/gems/erbse-0.1.3/lib/erbse/parser.rb:62:in `block in call'
I've had to change the template to lots of if .... elsif....
and that does work.
Hi,
Consider this ERB content:
<% if 'This is a string with the end keyword in it' %>
Content
<% end %>
I would expect this to parse fine. However, it seems that the "end" within the string is detected as an actual end
keyword.
Erbse::Engine.new.call("<% if 'This is a string with the end keyword in it' %> Content <% end %>")
NoMethodError: undefined method `<<' for nil:NilClass
from /usr/local/bundle/gems/erbse-0.1.4/lib/erbse/parser.rb:38:in `block in call'
It's not just within strings, but anything with "end" in it, for example and object of a class that defines an end
method:
<% if some_object.end %>
Content
<% end %>
The issue is that buffers
is an empty array on this line:
Line 33 in e36b5fa
With a template like:
abc
<%= 'foo' %>
def
I expected result
abc
foo
def
with erbse 0.1.3, I end up with a missing newline:
irb(main):004:0> puts Erbse::Engine.new.call("abc\n<%= 'foo' %>\ndef")
_buf = []; _buf << ("abc\n".freeze); _buf << ( 'foo' );
; _buf << ("def".freeze); _buf = _buf.join("".freeze)
# _buf == "abc\nfoodef"
Erbse fails with inline conditionals such as:
<%= f.input :captain_hired if boat.captain_available? && !boat.captain_mandatory? %>
This will produce an obscure error like the following:
SyntaxError:
app/concepts/boat_booker/views/show/_form.erb:5: syntax error, unexpected keyword_else, expecting keyword_end
; _buf << (" </div>\n ".freeze); else ;
^
app/concepts/boat_booker/views/show/_form.erb:12: syntax error, unexpected keyword_end, expecting end-of-input
end;end;end;end
^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.