Class: Jekyll::AssetsPlugin::Renderer
- Inherits:
-
Object
- Object
- Jekyll::AssetsPlugin::Renderer
- Defined in:
- lib/jekyll/assets_plugin/renderer.rb
Constant Summary collapse
- STYLESHEET =
'<link rel="stylesheet" href="%{path}"%{attrs}>'
- JAVASCRIPT =
'<script src="%{path}"%{attrs}></script>'
- IMAGE =
'<img src="%{path}"%{attrs}>'
- IMAGESIZE =
'width="%d" height="%d"'
- URI_RE =
%r{^(?:[^:]+:)?//(?:[^./]+\.)+[^./]+/}
- PARAMS_RE =
/ ^ \s* (?: "(?<path>[^"]+)" | '(?<path>[^']+)' | (?<path>[^ ]+) ) (?<attrs>.*?) (?: \[(?<options>.*)\] )? \s* $ /x
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(context, params) ⇒ Renderer
constructor
A new instance of Renderer.
- #render_asset ⇒ Object
- #render_asset_path ⇒ Object
- #render_image ⇒ Object
- #render_javascript ⇒ Object
- #render_stylesheet ⇒ Object
Constructor Details
#initialize(context, params) ⇒ Renderer
Returns a new instance of Renderer.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 24 def initialize(context, params) @site = context.registers[:site] match = params.strip.match PARAMS_RE @path = match["path"] @attrs = match["attrs"].strip @options = match["options"].to_s.split(",") @attrs = " #{@attrs}" unless @attrs.empty? end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
22 23 24 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 22 def attrs @attrs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 22 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 22 def path @path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
22 23 24 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 22 def site @site end |
Instance Method Details
#render_asset ⇒ Object
36 37 38 39 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 36 def render_asset fail "Can't render remote asset: #{path}" if remote? site.assets[path].to_s end |
#render_asset_path ⇒ Object
41 42 43 44 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 41 def render_asset_path return path if remote? site.asset_path path end |
#render_image ⇒ Object
54 55 56 57 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 54 def render_image autosize! render_tag IMAGE end |
#render_javascript ⇒ Object
46 47 48 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 46 def render_javascript render_tag JAVASCRIPT, ".js" end |
#render_stylesheet ⇒ Object
50 51 52 |
# File 'lib/jekyll/assets_plugin/renderer.rb', line 50 def render_stylesheet render_tag STYLESHEET, ".css" end |