Skip to content

Instantly share code, notes, and snippets.

@apotonick
Last active October 8, 2018 22:29
Show Gist options
  • Save apotonick/c69d63839e4062963fc4 to your computer and use it in GitHub Desktop.
Save apotonick/c69d63839e4062963fc4 to your computer and use it in GitHub Desktop.
Fucking Fuck Fuckers ERB and Fuck Rails And Fuck Haml And Fuck Their Fucking Fuck Hacks
## Smple
<pre>
"@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.safe_append='Word.\n\n'.freeze;@output_buffer.append= link_to \"/rails/sucks\" do @output_buffer.safe_append='\n hallo\n'.freeze; end \n@output_buffer.safe_append='\n'.freeze;@output_buffer.to_s"
</pre>
ActionView::Template::Handlers::Erubis.new "<%= form_for Object.new do %>\n <%= link do %>hallo<% end %> \n<% end %>"
```ruby
#<ActionView::Template::Handlers::Erubis:0x9613060 @escapefunc="Erubis::XmlHelper.escape_xml", @bufvar="_buf", @preamble=nil, @postamble=nil, @escape=nil, @pattern=nil, @trim=true, @filename=nil, @newline_pending=0, @_proc=nil, @src="@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.append= form_for Object.new do @output_buffer.safe_append='\n'.freeze; end ;@output_buffer.to_s">
ActionView::Template::Handlers::Erubis.new "<%= form_for Object.new do %>\n <%= link do %>hallo<% end %> \n<% end %>"
=>
#<ActionView::Template::Handlers::Erubis:0x9631fd8 @escapefunc="Erubis::XmlHelper.escape_xml", @bufvar="_buf", @preamble=nil, @postamble=nil, @escape=nil, @pattern=nil, @trim=true, @filename=nil, @newline_pending=0, @_proc=nil, @src="@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.append= form_for Object.new do @output_buffer.safe_append='\n '.freeze;@output_buffer.append= link do @output_buffer.safe_append='hallo'.freeze; end ;@output_buffer.safe_append=' \n'.freeze; end ;@output_buffer.to_s">
```
require "cell/erb"
=> true
2.1.2 :003 > Cells::Erubis.new "<%= form_for Object.new do %>\n <%= link do %>hallo<% end %> \n<% end %>"
add_preamble called§§§§§§§§§§
```ruby
#<Cells::Erubis:0xb71b12c @escapefunc="Erubis::XmlHelper.escape_xml", @bufvar="_buf", @preamble=nil, @postamble=nil, @escape=nil, @pattern=nil, @trim=true, @filename=nil, @newline_pending=0, @_proc=nil, @src="@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.append= form_for Object.new do @output_buffer.safe_append='\n '.freeze;@output_buffer.append= link do @output_buffer.safe_append='hallo'.freeze; end ;@output_buffer.safe_append=' \n'.freeze; end ;@output_buffer.to_s">
```
Tilt.new("tpl.erb", engine_class: Cell::Erubis)
class ErubisTemplate < ERBTemplate
.....
def prepare
@outvar = options.delete(:outvar) || self.class.default_output_variable
# raise @outvar.inspect
# @options.merge!(:preamble => false, :postamble => false, :bufvar => @outvar)
engine_class = options.delete(:engine_class)
# engine_class = ::Erubis::EscapedEruby if options.delete(:escape_html)
@engine = (engine_class || ::Erubis::Eruby).new(data, options)
end
@apotonick
Copy link
Author

THIS IS SO INCREDIBLY MESSY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment