Skip to content

mizalewski/cells-slim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cells::Slim

Support for Slim templates with Cells.

Installation

Add this line to your application's Gemfile:

gem 'cells-slim'

Usage

Outside of Rails, you need to include Cell::Slim in your cell.

class CommentCell < Cell::ViewModel
  include Cell::Slim

Important

Cells Slim change default settings for Slim and disables escaping in templates. To re-enable it, you can use below snippet:

It can be changed easy by override template_options_for from Cells::Slim:

module Cell
  module Slim
    def template_options_for(options)
      {
          template_class: ::Slim::Template,
          suffix: 'slim',
          disable_escape: false,
          escape_code: false,
          use_html_safe: false, # set true for Rails
          buffer: '@output_buffer'
      }
    end
  end
end

This can be put in config/application.rb.

Remember that you need to use '==' instead of '=' (reference in Slim docs) in your templates for code which should not be escaped, for example form_builder (notice that only from_for line require '=='):

== form_for model, url: users_path, method: method do |f|
  = f.text_field :first_name
  = f.text_field :last_name

Documentation

More documentation can be found on the Trailblazer page.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 91.6%
  • HTML 8.4%