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

Add constant for default content_tag_with_haml options #966

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,5 +1,6 @@
# Haml Changelog

* Add constant for default options in `lib/haml/helpers/action_view_mods.rb` [#966](https://github.com/haml/haml/pull/966) (thanks [Dillon Welch](https://github.com/oniofchaos))
* Performance/memory usage improvement in `lib/haml/buffer.rb` [#963](https://github.com/haml/haml/pull/963) (thanks [Dillon Welch](https://github.com/oniofchaos))
* Add erubis to gemspec so that `benchmark.rb` works [#964](https://github.com/haml/haml/pull/964) (thanks [Dillon Welch](https://github.com/oniofchaos))

Expand Down Expand Up @@ -1455,4 +1456,3 @@ has been moved to [YARD](http://yard.soen.ca).
YARD is an excellent documentation system,
and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
which is also excellent.
>>>>>>> External Changes
4 changes: 3 additions & 1 deletion lib/haml/helpers/action_view_mods.rb
Expand Up @@ -52,10 +52,12 @@ def capture_with_haml(*args, &block)
end

module TagHelper
DEFAULT_PRESERVE_OPTIONS = %w(textarea pre code).freeze

def content_tag_with_haml(name, *args, &block)
return content_tag_without_haml(name, *args, &block) unless is_haml?

preserve = haml_buffer.options.fetch(:preserve, %w[textarea pre code]).include?(name.to_s)
preserve = haml_buffer.options.fetch(:preserve, DEFAULT_PRESERVE_OPTIONS).include?(name.to_s)

if block_given? && block_is_haml?(block) && preserve
return content_tag_without_haml(name, *args) do
Expand Down