Module: Sinatra::EngineTracking

Included in:
Capture
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/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 collapse

Instance Method Summary collapse

Instance Attribute Details

#current_engineObject (readonly)

Returns the value of attribute current_engine.



9
10
11
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 9

def current_engine
  @current_engine
end

Instance Method Details

#builder?Boolean

Returns true if current engine is ‘:builder`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:builder`.



31
32
33
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 31

def builder?
  @current_engine == :builder
end

#erb?Boolean

Returns true if current engine is ‘:erb`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:erb`.



12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 12

def erb?
  @current_engine == :erb
end

#erubi?Boolean

Returns true if the current engine is ‘:erubi`, or `Tilt` is set to Tilt::ErubiTemplate.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:erubi`.



20
21
22
23
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 20

def erubi?
  @current_engine == :erubi or
    (erb? && Tilt[:erb] == Tilt::ErubiTemplate)
end

#haml?Boolean

Returns true if current engine is ‘:haml`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:haml`.



26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 26

def haml?
  @current_engine == :haml
end

#initializeObject



70
71
72
73
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 70

def initialize(*)
  @current_engine = :ruby
  super
end

#liquid?Boolean

Returns true if current engine is ‘:liquid`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:liquid`.



36
37
38
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 36

def liquid?
  @current_engine == :liquid
end

#markaby?Boolean

Returns true if current engine is ‘:markaby`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:markaby`.



51
52
53
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 51

def markaby?
  @current_engine == :markaby
end

#markdown?Boolean

Returns true if current engine is ‘:markdown`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:markdown`.



41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 41

def markdown?
  @current_engine == :markdown
end

#nokogiri?Boolean

Returns true if current engine is ‘:nokogiri`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:nokogiri`.



56
57
58
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 56

def nokogiri?
  @current_engine == :nokogiri
end

#rdoc?Boolean

Returns true if current engine is ‘:rdoc`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:rdoc`.



46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 46

def rdoc?
  @current_engine == :rdoc
end

#ruby?Boolean

Returns true if current engine is ‘:ruby`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:ruby`.



66
67
68
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 66

def ruby?
  @current_engine == :ruby
end

#slim?Boolean

Returns true if current engine is ‘:slim`.

Returns:

  • (Boolean)

    Returns true if current engine is ‘:slim`.



61
62
63
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 61

def slim?
  @current_engine == :slim
end

#with_engine(engine) ⇒ Object

Parameters:



76
77
78
79
80
81
82
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/engine_tracking.rb', line 76

def with_engine(engine)
  engine_was = @current_engine
  @current_engine = engine.to_sym
  yield
ensure
  @current_engine = engine_was
end