Comments (15)
If a template is prepended with an underscore, Camping shouldn't try to render the layout:
<%= render :_my_partial %>
from camping.
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.
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.
BTW the readable source on github is at camping/lib/camping-unabridged.rb - but you probably already found that.
from camping.
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.
@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.
When I try to require camping-unabridged I get weird errors!
from camping.
Show us the errors :-)
from camping.
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 class
Camping::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:in
require'
/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:in
load'
/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:in
reload!'
/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:in
each'
/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:in
update'
/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:in
reload!'
/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:in
call'
/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:in
call'
/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:in
call'
/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:in
service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:in
start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/lib/ruby/1.8/webrick/server.rb:162:in
start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:in
each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:in
start'
/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:in
run'
/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:in
start'
/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:in
load'
/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.
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.
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.
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.
Got it. And a beacon shone from the hill and they were enlightened.
from camping.
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.
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)
- Camping.io seems busted HOT 1
- The timeless repository HOT 1
- Launching app fails if we try to call create schema in our create method when we have no models mounted
- Unabridge camping-unabridged even more. HOT 2
- Trying to understand how Middleware works. HOT 2
- Broken link HOT 2
- Running an App will fail if an empty Model namespace is included with no migrations
- Document request cycle
- We should rename url_prefix to @root, and change how @root is set. HOT 1
- Invoking render in a view method ? HOT 6
- Write a Camping New helper HOT 3
- Get Guidebook working and tested to replace AR HOT 5
- Subdomains for Gear landing pages and documentation sites
- Explicitly include Rack Session HOT 1
- Add Rack Session as a dependency to fix the fact Rack Session is no longer included by default.
- Officially Add Support for Rack 3.0
- Make a common Utilities library Adjacent to Camping. HOT 1
- Builtin URL helpers don't support url_prefix. HOT 1
- Add Sequel gem support through van gem HOT 1
- [Chore] Rubygems release HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camping.