Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

65 lines (47 sloc) 2.375 kB

New Dependencies Proposal in 10 Easy (?) Steps

by Andy and Alex

  • rename Externals to Dependencies
  • rename external class method to depends_on
  • deprecate :script and :style
  • be smart about type -- rules follow:

(1) depends_on "" guesses "js" type links to

(5) depends_on :css, ".foo {color: chartreuse;}" can't guess type, so it must be specified embeds .foo {color: chartreuse;}

(6) depends_on "/scripts/bar.js" guesses "js" type links to

Or if you want all or most of your paths to become embedded, switch the global default to true:

(10) Erector::Widget.embed_dependencies = true

depends_on "/scripts/bar.js"
embeds contents of ROOT/public/bar.js: <script type="text/javascript">/* bar.js is the best! */...</script>

depends_on "/scripts/foo.js", :embed => false  # overrides the new default -- back to linking
links to <script src="/scripts/foo.js" />

Finally, if you want to evaluate your embedded code through a ruby string interpolation, use :interpolate => true. (We may want to replace this with ERB someday.)

Jump to Line
Something went wrong with that request. Please try again.