Last active
December 14, 2015 16:59
-
-
Save vic/5119557 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| %title {{title}} |
This file contains hidden or 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
| # A renderer that uses Rails asset pipeline and view caching | |
| class PageRenderer | |
| attr_reader :page | |
| def initialize(page) | |
| @page = page | |
| end | |
| def site | |
| page.site | |
| end | |
| def render(options = {}) | |
| options[:template] = page.layout if options.blank? | |
| content = view_renderer.render(self, options) | |
| Mustache.render content, self | |
| end | |
| def has_key?(name) | |
| name | |
| end | |
| def [](name) | |
| name | |
| end | |
| def theme | |
| @@theme ||= {} | |
| return @@theme[site.design] if @@theme[site.design] | |
| file = Rails.root.join("themes/#{site.design}/theme.yml") | |
| @@theme[site.design] = Class.new(Settingslogic) { source file } | |
| end | |
| def lookup_context | |
| site = page.site | |
| view_paths = ["themes/#{site.design}/views"] | |
| lookup_context = ActionView::LookupContext.new(view_paths) | |
| lookup_context.skip_default_locale! | |
| lookup_context.locale = site.locale | |
| lookup_context | |
| end | |
| def view_renderer | |
| ActionView::Renderer.new(lookup_context) | |
| end | |
| end |
This file contains hidden or 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
| !!! 5 | |
| %html | |
| != render partial: 'head' | |
| %body | |
| .hero-unit | |
| %h1 {{title}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment