The Bundled Resource Plugin - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

The Bundled Resource Plugin

Description:

Lightbox JS. Textarea Tools. Dojo Editor. qForms. Dynarch Calendar. Menus. Etc. The Manual Method ... Autoinclusion respects your controller class hierarchy. ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 12
Provided by: manu84
Category:

less

Transcript and Presenter's Notes

Title: The Bundled Resource Plugin


1
The Bundled Resource Plugin
  • A Better Way to Deal with Javascript and
    Stylesheet Dependencies in your Rails Applications

2
Cool Web 2.0 UI Components
  • Lightbox JS
  • Textarea Tools
  • Dojo Editor
  • qForms
  • Dynarch Calendar
  • Menus
  • Etc.

3
The Manual Method
Option A
  • Add javascript_include_tag and stylesheet_link_tag
    method calls within your applications layout.
  • Assumes all views need the same resources.
  • OK if you just have a handful of scripts or
    stylesheets.

4
The Manual Method
Option B
  • Include ltstylegtlt/stylegt and ltscriptgtlt/scriptgt
    tags within each view.
  • Allows views to specify their own dependencies.
  • Doesnt work well for partials (multiple calls).
  • No way to determine if a resource dependency has
    already been included somewhere else.
  • Produces unorganized HTML output.

5
The Bundled Resource Method
  • Add resource_tags to your layout.
  • Call require_javascript or require_stylesheet in
    your view or partial.
  • All script and link tags accumulate in the HEAD
    section.
  • No duplicates, even if called 2 times.
  • Bonus features

6
Bonus Features
  • Resources whose names match controllers or
    actions are included automatically.
  • Autoinclusion respects your controller class
    hierarchy.
  • And of course, the natural extension of all this
    groundwork is

7
Bundles
  • Call require_bundle name in the view files you
    know will need the named resource.
  • Lets you easily group images, javascripts and
    stylesheets in to a single package (nice when you
    develop more than one Rails app)
  • Same advantages as require_ calls so that you
    can specify your dependencies right at the source.

8
Lets See it in Family Connection
9
Engines, Plugins, Bundles and Components
  • All of them have some functional overlap, but
    lets highlight their separate strengths
  • Plugins provide a way for developers to extend
    the Rails core functionality
  • Engines bring functional groups of models, views,
    controllers, helpers and resources together for
    your app, and provide a mechanism for overriding
    behaviors.
  • Bundles bring resources and helpers together,
    primarily for isolated UI components.
  • Components allow for re-use of controller/view
    pairs.

10
Lets Dissect a Plugin
11
Contact and Further Reading
  • Duane Johnson duane_at_syncpeople.com
  • Company http//syncpeople.com/
  • My Blog http//blog.inquirylabs.com/
  • My Delicious Bookmarks http//del.icio.us/duane.j
    ohnson
Write a Comment
User Comments (0)
About PowerShow.com