phallstrom / box_tag Goto Github PK
View Code? Open in Web Editor NEWA Rails plugin to make generating styling boxed content simpler.
License: MIT License
A Rails plugin to make generating styling boxed content simpler.
License: MIT License
Rails 3! ======== In Rails 3, one can render a partial using a custom layout. That is, you can do this: <%= render :partial => "user", :layout => "administrator", :locals => { :user => administrator } %> So you can skip this plugin and add the following helper and get the same functionality. The only change that needs to be made is to join the "top" and "bottom" partials together and put a "<%= yield %>" where they meet. def box_tag(box = 'default', options = {}, &block) if box.is_a? Hash options = box.dup box = 'default' end render(:layout => "boxes/#{box}", :locals => { :options => options }) do capture(&block) if block_given? end end One upside to doing it this way is you can use HAML for your views. This plugin won't work with HAML as HAML closes all if it's tags and this plugin explicitly leaves some open. See 'Rendering partials with layouts' at http://api.rubyonrails.org/classes/ActionView/Partials.html for more information. BoxTag ====== Adds a 'box_tag' method which works similarly to 'content_tag', but instead of generating an HTML tag, renders the named partials around the content passed in the block. Example ======= <% box_tag(:fancy) do -%> some fancy content here including standard ERB stuff <% end %> The above will render the partial 'boxes/_fancy_top.html.erb', then capture the block content, then render the partial 'boxes/_fancy_bottom.html.erb'. <% box_tag(:fancy, :id => 'domid') do -%> the partials can now access :id by referencing options[:id]. this is true for any option passed. <% end %> <% box_tag(:class => 'foo') do -%> if you do not specify the box as the first argument it will assume you mean box_tag(:default, :class => 'foo'). <% end %> Copyright (c) 2008 Philip Hallstrom <[email protected]>, released under the MIT license
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.