Class: Utopia::Tags::EnvironmentTag

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(environment) ⇒ EnvironmentTag

Returns a new instance of EnvironmentTag

Parameters:

  • environment (Symbol)

    The name of the environment.



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