module Phlex::Helpers

def tokens(*tokens, **conditional_tokens)

Other tags:
    Example: With else condition -
    Example: With method conditions -
    Example: With Proc conditions -

Returns:
  • (String) -
def tokens(*tokens, **conditional_tokens)
	conditional_tokens.each do |condition, token|
		truthy = case condition
			when Symbol then send(condition)
			when Proc then condition.call
			else raise ArgumentError, "The class condition must be a Symbol or a Proc."
		end
		if truthy
			case token
				when Hash then __append_token__(tokens, token[:then])
				else __append_token__(tokens, token)
			end
		else
			case token
				when Hash then __append_token__(tokens, token[:else])
			end
		end
	end
	tokens = tokens.select(&:itself).join(" ")
	tokens.strip!
	tokens.gsub!(/\s+/, " ")
	tokens
end