Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created October 14, 2010 23:08
Show Gist options
  • Save luislavena/627257 to your computer and use it in GitHub Desktop.
Save luislavena/627257 to your computer and use it in GitHub Desktop.
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>
>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>'
# 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
! 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