123456789_123456789_123456789_123456789_123456789_

Module: Sinatra::HamlHelpers

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: sinatra-contrib/lib/sinatra/haml_helpers.rb

Overview

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

# now you can use the helpers in your views
get '/' do
  haml_code = <<~HAML
    %p
      != surround "(", ")" do
        %a{ href: "https://example.org/" } example.org
  HAML
  haml haml_code
end

end

Instance Attribute Summary

EngineTracking - Included

#builder?, #current_engine, #erb?,
#erubi?

Returns true if the current engine is :erubi, or Tilt[:erb] is set to Tilt::ErubiTemplate.

#haml?, #liquid?, #markaby?, #markdown?, #nokogiri?, #rdoc?, #ruby?, #sass?, #scss?, #slim?

Instance Method Summary

Instance Method Details

#_capture_haml(*args, &block)

[ GitHub ]

  
# File 'sinatra-contrib/lib/sinatra/haml_helpers.rb', line 44

def _capture_haml(*args, &block)
  capture(*args, &block)
end

#precede(str, &block)

[ GitHub ]

  
# File 'sinatra-contrib/lib/sinatra/haml_helpers.rb', line 36

def precede(str, &block)
  "#{str}#{_capture_haml(&block).chomp}\n"
end

#succeed(str, &block)

[ GitHub ]

  
# File 'sinatra-contrib/lib/sinatra/haml_helpers.rb', line 40

def succeed(str, &block)
  "#{_capture_haml(&block).chomp}#{str}\n"
end

#surround(front, back = front, &block)

[ GitHub ]

  
# File 'sinatra-contrib/lib/sinatra/haml_helpers.rb', line 32

def surround(front, back = front, &block)
  "#{front}#{_capture_haml(&block).chomp}#{back}\n"
end