Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

template helpers work well with current version of Tilt #9

Merged
merged 1 commit into from over 2 years ago

2 participants

Uchio KONDO Konstantin Haase
Uchio KONDO

Hi, rkh

I found that almost-sinatra.rb's template helpers mayn't work well with current version of Tilt.
So I created a patch.

Thank you!

Konstantin Haase rkh merged commit 9b72a89 into from December 01, 2011
Konstantin Haase rkh closed this December 01, 2011
Konstantin Haase
Owner

I'm curious: How did you run into this issue?

Uchio KONDO

I was interested in your almost-sinatra.rb code so I've analyzed the spaghetti.
I ran the sinatra-ish code below:

require 'haml'
require './almost_sinatra'

get '/' do
  "foobar"
end

get '/hi' do
  @title = "hello"
  haml :index
end

__END__

@@ index
%h1= @title
%p hello

Then I got the error undefined method 'new' for [Tilt::HamlTemplate]:Array,
and I found Tilt.mappings returns a String => Array of Engines hash.

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

Showing 1 unique commit by 1 author.

Dec 01, 2011
Uchio KONDO template helpers work well with current version of Tilt 89ec2fe
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  almost_sinatra.rb
2  almost_sinatra.rb
... ...
@@ -1,7 +1,7 @@
1 1
 %w.rack tilt backports INT TERM..map{|l|trap(l){$r.stop}rescue require l}
2 2
 $n=Sinatra=Module.new{extend Rack;a,D,S,$p,q,Application=Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m,4567,a
3 3
 %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}}}}
4  
-Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v.new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
  4
+Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h={};File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n.to_s==n ?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
5 5
 %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Handler.get("webrick").run(a,Port:$p){|s|$r=s}}
6 6
 %w[params session].map{|m|D.(m){q.send m}};a.use Session::Cookie;a.use Lock
7 7
 D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.