Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js & css is included inline to avoid asset installation
They're also built from templates.
- Loading branch information
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'mustache' | ||
|
||
module Whereuat | ||
module Assets | ||
class << self | ||
def rebuild! | ||
Whereuat.assets_path.mkpath | ||
|
||
Whereuat.javascript_file.open('w') {|f| f << Whereuat.javascript} | ||
Whereuat.css_file.open('w') {|f| f << Whereuat.css } | ||
end | ||
end | ||
|
||
autoload :Image , 'whereuat/assets/image' | ||
autoload :Context, 'whereuat/assets/context' | ||
|
||
def template_ctx | ||
Context.new | ||
end | ||
|
||
def javascript | ||
Mustache.render(javascript_template_file.read, Context.new) | ||
end | ||
|
||
def css | ||
Mustache.render(css_template_file.read, Context.new) | ||
end | ||
|
||
def dev_root | ||
@dev_root ||= gem_root+'dev' | ||
end | ||
|
||
def javascript_template_file | ||
@javascript_template_file ||= dev_root+'javascripts/whereuat.js.mustache' | ||
end | ||
|
||
def css_template_file | ||
@css_template_file ||= dev_root+'stylesheets/whereuat.css.mustache' | ||
end | ||
|
||
def javascript_file | ||
@javascript_file ||= assets_path+'whereuat.js' | ||
end | ||
|
||
def css_file | ||
@css_file ||= assets_path+'whereuat.css' | ||
end | ||
|
||
def inline_javascript | ||
javascript_file.exist? ? javascript_file.read : '' | ||
end | ||
|
||
def inline_css | ||
css_file.exist? ? css_file.read : '' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters