Giter Site home page Giter Site logo

Comments (15)

judofyr avatar judofyr commented on June 12, 2024

If a template is prepended with an underscore, Camping shouldn't try to render the layout:

<%= render :_my_partial %>

from camping.

zimbatm avatar zimbatm commented on June 12, 2024

Try prefixing your partials with an underscore. Camping used to use that as a distinction mechanism.-- Sent from my Palm PreOn 22 Sep 2011 18:35, igravious [email protected] wrote: At the moment (unless I am mistaken) you have to
<%= render(:my_partial, {:layout => false}) %>

but in Sinatra and possibly others they are smart enough not to invoke the magic function layout from partial templates. I'm sure this would be an easy tweak but I haven't a clue how to hack on Camping as the source is obfuscated. Pointers on how to hack on this would be welcome so I can submit a patch.

Reply to this email directly or view it on GitHub:
#41

from camping.

igravious avatar igravious commented on June 12, 2024

Okay. Thanks people. That works fine. But perhaps you want to use a template sometimes as a partial and sometimes as a whole page (when testing maybe, I dunno) - I still reckon Camping should be smart enough to know.

from camping.

DaveEveritt avatar DaveEveritt commented on June 12, 2024

BTW the readable source on github is at camping/lib/camping-unabridged.rb - but you probably already found that.

from camping.

judofyr avatar judofyr commented on June 12, 2024

I guess we could do something like this:

@_r=s=render(L,o.merge(L=>false)){s}if o[L]or o[L]!=!0&&(v.to_s[0]!=?_||!@_r)&&lookup(L)

English translation: Render the layout if :layout == true or (:layout != false and (the template begins with an underscore or the layout has not been rendered before) and there actually is a layout)

from camping.

igravious avatar igravious commented on June 12, 2024

@judofyr "not been rendered before" -> sounds great!

@DaveEveritt If I require 'camping-unabridged' then I can hack on camping, right? And make patches against this. I'll try it ...

from camping.

igravious avatar igravious commented on June 12, 2024

When I try to require camping-unabridged I get weird errors!

from camping.

judofyr avatar judofyr commented on June 12, 2024

Show us the errors :-)

from camping.

igravious avatar igravious commented on June 12, 2024

ok

** Starting WEBrick on 0.0.0.0:3301
[2011-09-27 10:40:34] INFO WEBrick 1.3.1
[2011-09-27 10:40:34] INFO ruby 1.8.7 (2011-02-18) [i686-linux]
[2011-09-27 10:40:34] INFO WEBrick::HTTPServer#start: pid=5508 port=3301
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:47: warning: already initialized constant C
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:48: warning: already initialized constant S
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:49: warning: already initialized constant P
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:50: warning: already initialized constant U
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:51: warning: already initialized constant O
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:52: warning: already initialized constant Apps
!! Error loading /var/www/localhost/htdocs/rack_apps/layout/config.ru:
NameError: undefined method id' for classCamping::H'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping-unabridged.rb:83
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in gem_original_require' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire'
/var/www/localhost/htdocs/rack_apps/layout/config.ru:18
/var/www/localhost/htdocs/rack_apps/layout/config.ru:18:in each' /var/www/localhost/htdocs/rack_apps/layout/config.ru:18 /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:60:inload'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:60:in load_apps' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:105:inreload!'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:180:in reload!' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:179:ineach'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:179:in reload!' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/reloader.rb:158:inupdate'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:157:in find_scripts' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:161:inreload!'
/usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:169:in call' /usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/lint.rb:48:in_call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/lint.rb:36:in call' /usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/showexceptions.rb:24:incall'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/commonlogger.rb:20:in call' /usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/chunked.rb:41:incall'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/content_length.rb:14:in call' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:242:incall'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/handler/webrick.rb:59:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:inservice'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:instart_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/lib/ruby/1.8/webrick/server.rb:162:instart_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:ineach'
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:instart'
/usr/lib/ruby/1.8/webrick/server.rb:82:in start' /usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/handler/webrick.rb:13:inrun'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/server.rb:265:in start' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/../lib/camping/server.rb:144:instart'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.2/lib/rack/server.rb:137:in start' /usr/lib/ruby/gems/1.8/gems/camping-2.1/bin/camping:9 /usr/bin/camping:19:inload'
/usr/bin/camping:19
!! Error loading /var/www/localhost/htdocs/rack_apps/layout/config.ru, see backtrace above
130.234.189.28 - - [27/Sep/2011 10:40:39] "GET /home HTTP/1.1" 200 - 0.0343

from camping.

judofyr avatar judofyr commented on June 12, 2024

You'll need to require camping-unabridged before camping. Try something like this in the camping directory:

ruby -Ilib -rcamping-unabridged bin/camping app.rb

from camping.

igravious avatar igravious commented on June 12, 2024

Oh. I was requiring it instead of camping. I thought it was a drop in replacement. Just to be clear. We are talking about the library camping.rb here, not camping server aren't we?

from camping.

judofyr avatar judofyr commented on June 12, 2024

Yeah, it's a replacement for camping.rb, but bin/camping requires camping.rb for you. So you'll have to require camping-unabridged.rb before bin/camping.

from camping.

igravious avatar igravious commented on June 12, 2024

Got it. And a beacon shone from the hill and they were enlightened.

from camping.

igravious avatar igravious commented on June 12, 2024

Nice work, I must test it out. The following is the command I use to launch bin/camping
ruby -rubygems -r$(locate camping-unabridged.rb) $(which camping) rack_apps/*/config.ru
notice that I do not have any -Ilib... do I need it, do you think?

from camping.

judofyr avatar judofyr commented on June 12, 2024

To answer your question: Because you don't have a -Ilib, stuff like require "camping/server" will load from the Gem (not the directory). If there's only been changes in camping-unabridged it shouldn't be a problem.

from camping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.