Skip to content

Instantly share code, notes, and snippets.

@evg2108
Last active February 4, 2019 06:41
Show Gist options
  • Save evg2108/17e93bf7e1395b751ddf to your computer and use it in GitHub Desktop.
Save evg2108/17e93bf7e1395b751ddf to your computer and use it in GitHub Desktop.
render string as slim template

#render string as slim template

example:

module WelcomeHelper
  def tile_link_to(title, href, icon_content = nil, &block)
    icon_content = capture { block.call }.strip.squish if block_given?
    content = <<-slim
      .tile
        a.wrap_lnk href="#{href}"
        span.title #{title}
        .icon
          #{icon_content}
    slim
    Slim::Template.new{ content }.render.html_safe
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment