Class: Utopia::Tags::EnvironmentTag
- Inherits:
-
Object
- Object
- Utopia::Tags::EnvironmentTag
- Defined in:
- lib/utopia/content/tags/environment_tag.rb
Overview
A conditional tag which only exposes it’s content in certain environments.
Instance Method Summary collapse
-
#call(document, state) ⇒ Object
-
#initialize(environment) ⇒ EnvironmentTag
constructor
A new instance of EnvironmentTag.
Constructor Details
#initialize(environment) ⇒ EnvironmentTag
Returns a new instance of EnvironmentTag
26 27 28 |
# File 'lib/utopia/content/tags/environment_tag.rb', line 26 def initialize(environment) @environment = environment end |
Instance Method Details
#call(document, state) ⇒ Object
TODO:
improve implementation
31 32 33 34 35 36 37 |
# File 'lib/utopia/content/tags/environment_tag.rb', line 31 def call(document, state) only = state[:only].split(",").collect(&:to_sym) rescue [] if only.include?(@environment) document.parse_markup(state.content) end end |