Module: VizBuilder::TemplateHelpers
- Defined in:
- lib/vizbuilder.rb
Overview
The TemplateHelpers modules hold methods that are added to the template context only. So you can only use these in templates.
Instance Method Summary collapse
-
#asset_http_prefix ⇒ Object
Get the full URL to the root of where assets are stored.
-
#asset_path(*args) ⇒ Object
Generate and return the URL to any asset.
-
#canonical_url(*args) ⇒ Object
Generate and return the URL to any page.
-
#http_prefix ⇒ Object
Get the full URL to the root of this site.
Instance Method Details
#asset_http_prefix ⇒ Object
Get the full URL to the root of where assets are stored
375 376 377 378 379 |
# File 'lib/vizbuilder.rb', line 375 def asset_http_prefix prefix = config[:asset_http_prefix] || http_prefix prefix += '/' unless prefix =~ %r{/$} prefix end |
#asset_path(*args) ⇒ Object
Generate and return the URL to any asset
382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/vizbuilder.rb', line 382 def asset_path(*args) path = args.join('/') page = sitemap[path] if production? raise "Missing asset #{path}" if page.blank? if page[:digest] == true raise "Missing digest for #{path}" if page[:digest_path].blank? path = page[:digest_path] end end asset_http_prefix + path end |
#canonical_url(*args) ⇒ Object
Generate and return the URL to any page
396 397 398 |
# File 'lib/vizbuilder.rb', line 396 def canonical_url(*args) http_prefix + args.join('/') end |
#http_prefix ⇒ Object
Get the full URL to the root of this site
368 369 370 371 372 |
# File 'lib/vizbuilder.rb', line 368 def http_prefix prefix = config[:http_prefix] || '/' prefix += '/' unless prefix =~ %r{/$} prefix end |