Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added how to re-enable Slim escaping #12

Merged
merged 1 commit into from
Aug 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@ 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**:
```ruby
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](http://www.rubydoc.info/gems/slim/frames#Output_without_HTML_escaping___)) 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](http://trailblazerb.org/gems/cells/templates.html) can be found on the Trailblazer page.