Module: Sinatra::HamlHelpers
- Includes:
- Capture
- Defined in:
- lib/sinatra/haml_helpers.rb
Overview
Sinatra::HamlHelpers
This extension provides some of the helper methods that existed in Haml 5 but were removed in Haml 6. To use this in your app, just register
it:
require 'sinatra/base'
require 'sinatra/haml_helpers'
class Application < Sinatra::Base
helpers Sinatra::HamlHelpers
get '/' do
haml_code = <<~HAML
%p
!= surround "(", ")" do
%a{ href: "https://example.org/" } example.org
HAML
haml haml_code
end
end
Instance Attribute Summary
#current_engine
Instance Method Summary
collapse
Methods included from Capture
#capture, #capture_later
#builder?, #erb?, #erubi?, #haml?, #initialize, #liquid?, #markaby?, #markdown?, #nokogiri?, #rdoc?, #ruby?, #sass?, #scss?, #slim?, #with_engine
Instance Method Details
#_capture_haml(*args, &block) ⇒ Object
44
45
46
|
# File 'lib/sinatra/haml_helpers.rb', line 44
def _capture_haml(*args, &block)
capture(*args, &block)
end
|
#precede(str, &block) ⇒ Object
36
37
38
|
# File 'lib/sinatra/haml_helpers.rb', line 36
def precede(str, &block)
"#{str}#{_capture_haml(&block).chomp}\n"
end
|
#succeed(str, &block) ⇒ Object
40
41
42
|
# File 'lib/sinatra/haml_helpers.rb', line 40
def succeed(str, &block)
"#{_capture_haml(&block).chomp}#{str}\n"
end
|
#surround(front, back = front, &block) ⇒ Object
32
33
34
|
# File 'lib/sinatra/haml_helpers.rb', line 32
def surround(front, back = front, &block)
"#{front}#{_capture_haml(&block).chomp}#{back}\n"
end
|