Created
October 14, 2010 23:08
-
-
Save luislavena/627257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby t.rb | |
<!doctype html><html><head><title>Test</title></head><body></body><ol><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ol></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>ruby t.rb | |
C:/Users/Luis/.gem/ruby/x86-mingw32/1.9.1/gems/slim-0.6.0.beta.2/lib/slim/engine.rb:16:in `instance_eval': undefined method `item' for #<Context:0x2769000 @items=[1, 2, 3, 4, 5]> (NoMethodError) | |
from (eval):1:in `each' | |
from (eval):1:in `render' | |
from C:/Users/Luis/.gem/ruby/x86-mingw32/1.9.1/gems/slim-0.6.0.beta.2/lib/slim/engine.rb:16:in `instance_eval' | |
from C:/Users/Luis/.gem/ruby/x86-mingw32/1.9.1/gems/slim-0.6.0.beta.2/lib/slim/engine.rb:16:in `render' | |
from t.rb:13:in `<main>' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uncomment below to test against 0.5 | |
#gem 'slim', '~> 0.5.0' | |
require 'slim' | |
class Context | |
attr_reader :items | |
def initialize | |
@items = [1, 2, 3, 4, 5] | |
end | |
end | |
c = Context.new | |
v = File.read('view.html.slim') | |
e = Slim::Engine.new(v) | |
r = e.render(c) | |
puts r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! doctype html | |
html | |
head | |
title Test | |
body | |
- unless items.empty? | |
ol | |
- items.each do |item| | |
li | |
= item | |
- else | |
p No items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment