Module: Sinatra::EngineTracking
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | sinatra-contrib/lib/sinatra/engine_tracking.rb |
Overview
Adds methods like #haml? that allow helper methods to check whether they are called from within a template.
Instance Attribute Summary
- #builder? ⇒ Boolean readonly
- #current_engine readonly
- #erb? ⇒ Boolean readonly
-
#erubi? ⇒ Boolean
readonly
Returns true if the current engine is
:erubi
, orTilt[:erb]
is set to Tilt::ErubiTemplate. - #haml? ⇒ Boolean readonly
- #liquid? ⇒ Boolean readonly
- #markaby? ⇒ Boolean readonly
- #markdown? ⇒ Boolean readonly
- #nokogiri? ⇒ Boolean readonly
- #rdoc? ⇒ Boolean readonly
- #ruby? ⇒ Boolean readonly
- #sass? ⇒ Boolean readonly
- #scss? ⇒ Boolean readonly
- #slim? ⇒ Boolean readonly
Instance Method Summary
Instance Attribute Details
#builder? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 41
def builder? @current_engine == :builder end
#current_engine (readonly)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 9
attr_reader :current_engine
#erb? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 12
def erb? @current_engine == :erb end
#erubi? ⇒ Boolean
(readonly)
Returns true if the current engine is :erubi
, or Tilt[:erb]
is set
to Tilt::ErubiTemplate.
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 20
def erubi? @current_engine == :erubi or (erb? && Tilt[:erb] == Tilt::ErubiTemplate) end
#haml? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 26
def haml? @current_engine == :haml end
#liquid? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 46
def liquid? @current_engine == :liquid end
#markaby? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 61
def markaby? @current_engine == :markaby end
#markdown? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 51
def markdown? @current_engine == :markdown end
#nokogiri? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 66
def nokogiri? @current_engine == :nokogiri end
#rdoc? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 56
def rdoc? @current_engine == :rdoc end
#ruby? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 76
def ruby? @current_engine == :ruby end
#sass? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 31
def sass? @current_engine == :sass end
#scss? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 36
def scss? @current_engine == :scss end
#slim? ⇒ Boolean
(readonly)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 71
def slim? @current_engine == :slim end
Instance Method Details
#initialize
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 80
def initialize(*) @current_engine = :ruby super end
#render(engine) (private)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 96
def render(engine, *) with_engine(engine) { super } end
#with_engine(engine)
# File 'sinatra-contrib/lib/sinatra/engine_tracking.rb', line 86
def with_engine(engine) engine_was = @current_engine @current_engine = engine.to_sym yield ensure @current_engine = engine_was end