', body
+
+ get '/with_layout'
+ assert ok?
+ assert_equal 'this is a span', body
+ end
+
+ should 'render haml to a SafeBuffer' do
+ mock_app do
+ layout do
+ "%p= yield"
+ end
+ get '/' do
+ render :haml, '%p= %s{}', :layout => false
+ end
+ get '/with_layout' do
+ render :haml, "%div\n foo", :layout => true
+ end
+ end
+ get '/'
+ assert ok?
+ assert_equal '
', body.gsub(/\s+/, "")
+ end
+
+ should 'render slim to a SafeBuffer' do
+ mock_app do
+ layout do
+ "p= yield"
+ end
+ get '/' do
+ render :slim, 'p = %q{}', :layout => false
+ end
+ get "/with_layout" do
+ render :slim, 'div foo', :layout => true
+ end
+ end
+ get '/'
+ assert ok?
+ assert_equal '
+ #
+ #
+ # @api public
+ def breadcrumbs(breadcrumbs, bootstrap=false, active="active")
+ content=""
+ breadcrumbs.items[0..-2].each do |item|
+ content << render_item(item, bootstrap)
+ end
+ last = link_to(breadcrumbs.items.last[:caption], breadcrumbs.items.last[:url])
+ content << safe_content_tag(:li, last, :class => active)
+ safe_content_tag(:ul, content, :class => "breadcrumb" )
+ end
+
+ private
+ ##
+ # Private method to return list item
+ #
+ # @param [Hash] item
+ # The breadcrumb item
+ #
+ # @param [Boolean] bootstrap
+ # If true, render separation (usefull with Twitter Bootstrap)
+ #
+ # @return [String] List item with breacrumb
+ #
+ # @api public
+ def render_item(item, bootstrap)
+ content = ""
+ content << link_to(item[:caption], item[:url])
+ content << safe_content_tag(:span, "/", :class => "divider") if bootstrap
+ safe_content_tag(:li, content )
+ end
+
+ end # Breadcrumb
+ end # Helpers
+end # Padrino
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_builder/abstract_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_builder/abstract_form_builder.rb
similarity index 72%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_builder/abstract_form_builder.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_builder/abstract_form_builder.rb
index 2d279be9..4d5e54e8 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_builder/abstract_form_builder.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_builder/abstract_form_builder.rb
@@ -24,9 +24,9 @@ module Padrino
end
# f.label :username, :caption => "Nickname"
- def label(field, options={})
+ def label(field, options={}, &block)
options.reverse_merge!(:caption => "#{field_human_name(field)}: ")
- @template.label_tag(field_id(field), options)
+ @template.label_tag(field_id(field), options, &block)
end
# f.hidden_field :session_id, :value => "45"
@@ -95,12 +95,38 @@ module Padrino
@template.select_tag field_name(field), options
end
+ # f.check_box_group :color, :options => ['red', 'green', 'blue'], :selected => ['red', 'blue']
+ # f.check_box_group :color, :collection => @colors, :fields => [:name, :id]
+ def check_box_group(field, options={})
+ selected_values = Array(options[:selected] || field_value(field))
+ if options[:collection]
+ fields = options[:fields] || [:name, :id]
+ # don't use map!, it will break some orms
+ selected_values = selected_values.map{ |v| (v.respond_to?(fields[0]) ? v.send(fields[1]) : v).to_s }
+ end
+ labeled_group( field, options ) do |variant|
+ @template.check_box_tag( field_name(field)+'[]', :value => variant[1], :id => variant[2], :checked => selected_values.include?(variant[1]) )
+ end
+ end
+
+ # f.radio_button_group :color, :options => ['red', 'green']
+ # f.radio_button_group :color, :collection => @colors, :fields => [:name, :id], :selected => @colors.first
+ def radio_button_group(field, options={})
+ fields = options[:fields] || [:name, :id]
+ selected_value = options[:selected] || field_value(field)
+ selected_value = selected_value.send(fields[1]) if selected_value.respond_to?(fields[0])
+ labeled_group( field, options ) do |variant|
+ @template.radio_button_tag( field_name(field), :value => variant[1], :id => variant[2], :checked => variant[1] == selected_value.to_s )
+ end
+ end
+
# f.check_box :remember_me, :value => 'true', :uncheck_value => '0'
def check_box(field, options={})
+ html = ActiveSupport::SafeBuffer.new
unchecked_value = options.delete(:uncheck_value) || '0'
options.reverse_merge!(:id => field_id(field), :value => '1')
options.reverse_merge!(:checked => true) if values_matches_field?(field, options[:value])
- html = @template.hidden_field_tag(options[:name] || field_name(field), :value => unchecked_value, :id => nil)
+ html << @template.hidden_field_tag(options[:name] || field_name(field), :value => unchecked_value, :id => nil)
html << @template.check_box_tag(field_name(field), options)
end
@@ -140,7 +166,11 @@ module Padrino
result = nested_objects.each_with_index.map do |child_instance, index|
nested_options[:index] = include_index ? index : nil
@template.fields_for(child_instance, { :nested => nested_options }, &block)
- end.join("\n")
+ end.join("\n").html_safe
+ end
+
+ def csrf_token_field
+ @template.csrf_token_field
end
protected
@@ -171,17 +201,8 @@ module Padrino
# field_name(:number) => "user[telephone_attributes][number]"
# field_name(:street) => "user[addresses_attributes][0][street]"
def field_name(field=nil)
- result = []
- if root_form?
- result << object_model_name
- elsif nested_form?
- parent_form = @options[:nested][:parent]
- attributes_name = "#{@options[:nested][:association]}_attributes"
- nested_index = @options[:nested][:index]
- fragment = [parent_form.field_name, "[#{attributes_name}", "]"]
- fragment.insert(2, "][#{nested_index}") if nested_index
- result << fragment
- end
+ result = field_result
+ result << field_name_fragment if nested_form?
result << "[#{field}]" unless field.blank?
result.flatten.join
end
@@ -192,17 +213,8 @@ module Padrino
# field_name(:number) => "user_telephone_attributes_number"
# field_name(:street) => "user_addresses_attributes_0_street"
def field_id(field=nil, value=nil)
- result = []
- if root_form?
- result << object_model_name
- elsif nested_form?
- parent_form = @options[:nested][:parent]
- attributes_name = "#{@options[:nested][:association]}_attributes"
- nested_index = @options[:nested][:index]
- fragment = [parent_form.field_id, "_#{attributes_name}"]
- fragment.push("_#{nested_index}") if nested_index
- result << fragment
- end
+ result = field_result
+ result << field_id_fragment if nested_form?
result << "_#{field}" unless field.blank?
result << "_#{value}" unless value.blank?
result.flatten.join
@@ -245,6 +257,52 @@ module Padrino
def root_form?
!nested_form?
end
+
+ # Builds a group of labels for radios or checkboxes
+ def labeled_group(field, options={})
+ options.reverse_merge!(:id => field_id(field), :selected => field_value(field))
+ options.merge!(:class => field_error(field, options))
+ variants = case
+ when options[:options]
+ options[:options].map{ |caption, value| [caption.to_s, (value||caption).to_s] }
+ when options[:collection]
+ fields = options[:fields] || [:name, :id]
+ options[:collection].map{ |variant| [variant.send(fields.first).to_s, variant.send(fields.last).to_s] }
+ else
+ []
+ end
+ variants.inject(''.html_safe) do |html, variant|
+ variant[2] = "#{field_id(field)}_#{variant[1]}"
+ html << @template.label_tag("#{field_name(field)}[]", :for => variant[2], :caption => "#{yield(variant)} #{variant[0]}")
+ end
+ end
+
+ private
+ def field_result
+ result = []
+ result << object_model_name if root_form?
+ result
+ end
+
+ def field_name_fragment
+ fragment = [result_options[:parent_form].field_name, "[#{result_options[:attributes_name]}", "]"]
+ fragment.insert(2, "][#{result_options[:nested_index]}") if result_options[:nested_index]
+ fragment
+ end
+
+ def field_id_fragment
+ fragment = [result_options[:parent_form].field_id, "_#{result_options[:attributes_name]}"]
+ fragment.push("_#{result_options[:nested_index]}") if result_options[:nested_index]
+ fragment
+ end
+
+ def result_options
+ {
+ :parent_form => @options[:nested][:parent],
+ :nested_index => @options[:nested][:index],
+ :attributes_name => "#{@options[:nested][:association]}_attributes"
+ }
+ end
end # AbstractFormBuilder
end # FormBuilder
end # Helpers
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_builder/standard_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_builder/standard_form_builder.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_builder/standard_form_builder.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_builder/standard_form_builder.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_helpers.rb
similarity index 89%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_helpers.rb
index cc8ee5ba..7a03977d 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/form_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/form_helpers.rb
@@ -1,3 +1,5 @@
+require 'securerandom'
+
module Padrino
module Helpers
##
@@ -28,8 +30,9 @@ module Padrino
#
# @api public
def form_for(object, url, settings={}, &block)
- form_html = capture_html(builder_instance(object, settings), &block)
- form_tag(url, settings) { form_html }
+ instance = builder_instance(object, settings)
+ html = capture_html(instance, &block)
+ form_tag(url, settings) { html }
end
##
@@ -54,7 +57,7 @@ module Padrino
instance = builder_instance(object, settings)
fields_html = capture_html(instance, &block)
fields_html << instance.hidden_field(:id) if instance.send(:nested_object_id)
- concat_content fields_html
+ concat_safe_content fields_html
end
##
@@ -79,8 +82,9 @@ module Padrino
options.reverse_merge!(:method => 'post', :action => url)
options[:enctype] = 'multipart/form-data' if options.delete(:multipart)
options['accept-charset'] ||= 'UTF-8'
- inner_form_html = hidden_form_method_field(desired_method)
- inner_form_html += capture_html(&block)
+ inner_form_html = hidden_form_method_field(desired_method)
+ inner_form_html << csrf_token_field
+ inner_form_html << mark_safe(capture_html(&block))
concat_content content_tag(:form, inner_form_html, options)
end
@@ -100,7 +104,7 @@ module Padrino
#
# @api semipublic
def hidden_form_method_field(desired_method)
- return '' if desired_method.blank? || desired_method.to_s =~ /get|post/i
+ return ActiveSupport::SafeBuffer.new if desired_method.blank? || desired_method.to_s =~ /get|post/i
hidden_field_tag(:_method, :value => desired_method)
end
@@ -125,8 +129,8 @@ module Padrino
def field_set_tag(*args, &block)
options = args.extract_options!
legend_text = args[0].is_a?(String) ? args.first : nil
- legend_html = legend_text.blank? ? '' : content_tag(:legend, legend_text)
- field_set_content = legend_html + capture_html(&block)
+ legend_html = legend_text.blank? ? ActiveSupport::SafeBuffer.new : content_tag(:legend, legend_text)
+ field_set_content = legend_html + mark_safe(capture_html(&block))
concat_content content_tag(:fieldset, field_set_content, options)
end
@@ -167,7 +171,7 @@ module Padrino
objects = objects.map { |object_name|
object_name.is_a?(Symbol) ? instance_variable_get("@#{object_name}") : object_name
}.compact
- count = objects.inject(0) { |sum, object| sum + object.errors.size }
+ count = objects.inject(0) { |sum, object| sum + object.errors.count }
unless count.zero?
html = {}
@@ -199,10 +203,10 @@ module Padrino
}
}.join
- contents = ''
+ contents = ActiveSupport::SafeBuffer.new
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
contents << content_tag(:p, message) unless message.blank?
- contents << content_tag(:ul, error_messages)
+ contents << safe_content_tag(:ul, error_messages)
content_tag(:div, contents, html)
end
@@ -244,7 +248,14 @@ module Padrino
def error_message_on(object, field, options={})
object = object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object
error = object.errors[field] rescue nil
- # Array(error).first is necessary because some ORMs give us an array others directly a value
+ error = if defined?(Ohm::Model) && object.is_a?(Ohm::Model)
+ I18n.t("ohm.errors.messages.#{error[0]}", :default => error[0].to_s)
+ else
+ # Array(error).first is necessary because some ORMs
+ # give us an array others directly a value
+ Array(error)[0]
+ end
+
if error = Array(error)[0]
options.reverse_merge!(:tag => :span, :class => :error)
tag = options.delete(:tag)
@@ -276,10 +287,11 @@ module Padrino
# @api public
def label_tag(name, options={}, &block)
options.reverse_merge!(:caption => "#{name.to_s.humanize}: ", :for => name)
- caption_text = options.delete(:caption)
- caption_text << "* " if options.delete(:required)
+ caption_text = options.delete(:caption).html_safe
+ caption_text.safe_concat "* " if options.delete(:required)
+
if block_given? # label with inner content
- label_content = caption_text + capture_html(&block)
+ label_content = caption_text.concat capture_html(&block)
concat_content(content_tag(:label, label_content, options))
else # regular label
content_tag(:label, caption_text, options)
@@ -409,10 +421,10 @@ module Padrino
# # =>
#
# @api public
- def number_field_tag(name, options={})
+ def number_field_tag(name, options={})
input_tag(:number, options.reverse_merge(:name => name))
end
-
+
##
# Creates a telephone field input with the given name and options
#
@@ -452,7 +464,7 @@ module Padrino
def email_field_tag(name, options={})
input_tag(:email, options.reverse_merge(:name => name))
end
-
+
##
# Creates a search field input with the given name and options
#
@@ -573,6 +585,7 @@ module Padrino
#
# @api public
def file_field_tag(name, options={})
+ name = "#{name}[]" if options[:multiple]
options.reverse_merge!(:name => name)
input_tag(:file, options)
end
@@ -630,7 +643,7 @@ module Padrino
end
select_options_html = select_options_html.unshift(blank_option(prompt)) if select_options_html.is_a?(Array)
options.merge!(:name => "#{options[:name]}[]") if options[:multiple]
- content_tag(:select, select_options_html, options)
+ safe_content_tag(:select, select_options_html, options)
end
##
@@ -689,6 +702,68 @@ module Padrino
input_tag(:image, options)
end
+ # Constructs a hidden field containing a CSRF token.
+ #
+ # @param [String] token
+ # The token to use. Will be read from the session by default.
+ #
+ # @return [String] The hidden field with CSRF token as value.
+ #
+ # @example
+ # csrf_token_field
+ #
+ # @api public
+ def csrf_token_field(token = nil)
+ if defined? session
+ token ||= (session[:csrf] ||= SecureRandom.hex(32))
+ end
+
+ hidden_field_tag :authenticity_token, :value => token
+ end
+
+ ##
+ # Creates a form containing a single button that submits to the url.
+ #
+ # @overload button_to(name, url, options={})
+ # @param [String] caption The text caption.
+ # @param [String] url The url href.
+ # @param [Hash] options The html options.
+ # @overload button_to(name, options={}, &block)
+ # @param [String] url The url href.
+ # @param [Hash] options The html options.
+ # @param [Proc] block The button content.
+ #
+ # @option options [Boolean] :multipart
+ # If true, this form will support multipart encoding.
+ # @option options [String] :remote
+ # Instructs ujs handler to handle the submit as ajax.
+ # @option options [Symbol] :method
+ # Instructs ujs handler to use different http method (i.e :post, :delete).
+ #
+ # @return [String] Form and button html with specified +options+.
+ #
+ # @example
+ # button_to 'Delete', url(:accounts_destroy, :id => account), :method => :delete, :class => :form
+ # # Generates:
+ # #
+ #
+ # @api public
+ def button_to(*args, &block)
+ name, url = args[0], args[1]
+ options = args.extract_options!
+ options['data-remote'] = 'true' if options.delete(:remote)
+ if block_given?
+ form_tag(url, options, &block)
+ else
+ form_tag(url, options) do
+ submit_tag(name)
+ end
+ end
+ end
+
protected
##
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/format_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/format_helpers.rb
similarity index 97%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/format_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/format_helpers.rb
index ce661d5b..506590b6 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/format_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/format_helpers.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
module Padrino
module Helpers
###
@@ -18,7 +19,7 @@ module Padrino
#
# @api public
def escape_html(text)
- Rack::Utils.escape_html(text)
+ Rack::Utils.escape_html(text).html_safe
end
alias h escape_html
alias sanitize_html escape_html
@@ -40,8 +41,8 @@ module Padrino
#
# @api public
def h!(text, blank_text = ' ')
- return blank_text if text.nil? || text.empty?
- h text
+ return blank_text.html_safe if text.nil? || text.empty?
+ h(text)
end
##
@@ -82,12 +83,13 @@ module Padrino
def simple_format(text, options={})
t = options.delete(:tag) || :p
start_tag = tag(t, options, true)
- text = text.to_s.dup
+ text = escape_html(text.to_s.dup)
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "#{t}>\n\n#{start_tag}") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1 ') # 1 newline -> br
text.insert 0, start_tag
text << "#{t}>"
+ text.html_safe
end
##
@@ -373,7 +375,9 @@ module Padrino
def js_escape_html(html_content)
return '' unless html_content
javascript_mapping = { '\\' => '\\\\', '' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
- html_content.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { javascript_mapping[$1] }
+ escaped_content = html_content.gsub(/(\\|<\/|\r\n|[\n\r"'])/){ |m| javascript_mapping[m] }
+ escaped_content = escaped_content.html_safe if html_content.html_safe?
+ escaped_content
end
alias :escape_javascript :js_escape_html
end # FormatHelpers
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/cs.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/cs.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/cs.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/cs.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/da.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/da.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/da.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/da.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/de.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/de.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/de.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/de.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/en.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/en.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/en.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/en.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/es.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/es.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/es.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/es.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/fr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/fr.yml
similarity index 81%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/fr.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/fr.yml
index 72113130..9f300f89 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/fr.yml
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/fr.yml
@@ -27,25 +27,25 @@ fr:
format: "%n %u"
units:
byte:
- one: "Byte"
- other: "Bytes"
- kb: "KB"
- mb: "MB"
- gb: "GB"
- tb: "TB"
+ one: "Octet"
+ other: "Octets"
+ kb: "Ko"
+ mb: "Mo"
+ gb: "Go"
+ tb: "To"
datetime:
distance_in_words:
half_a_minute: "une demi minute"
less_than_x_seconds:
- one: "infèrieur à une seconde"
- other: "infèrieur à %{count} secondes"
+ one: "inférieur à une seconde"
+ other: "inférieur à %{count} secondes"
x_seconds:
one: "1 seconde"
other: "%{count} secondes"
less_than_x_minutes:
- one: "infèrieur à 1 minute"
- other: "infèrieur à %{count} minutes"
+ one: "inférieur à 1 minute"
+ other: "inférieur à %{count} minutes"
x_minutes:
one: "1 minute"
other: "%{count} minutes"
@@ -68,8 +68,8 @@ fr:
one: "plus d'un an"
other: "plus de %{count} ans"
almost_x_years:
- one: "près d'un ans"
- other: "près de %{count} years"
+ one: "près d'un an"
+ other: "près de %{count} ans"
models:
errors:
template:
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/hu.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/hu.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/hu.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/hu.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/it.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/it.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/it.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/it.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ja.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ja.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ja.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ja.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/lv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/lv.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/lv.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/lv.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/nl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/nl.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/nl.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/nl.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/no.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/no.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/no.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/no.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/pl.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/pl.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/pl.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/pl.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/pt_br.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/pt_br.yml
similarity index 98%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/pt_br.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/pt_br.yml
index 35c4b1bc..ee5ea2f3 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/pt_br.yml
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/pt_br.yml
@@ -17,8 +17,8 @@ pt_br:
format: "%u%n"
unit: "R$"
# These three are to override number.format and are optional
- separator: "."
- delimiter: ","
+ separator: ","
+ delimiter: "."
precision: 2
# Used in number_to_percentage()
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ro.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ro.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ro.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ro.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ru.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ru.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/ru.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/ru.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/sv.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/sv.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/sv.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/sv.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/tr.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/tr.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/tr.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/tr.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/uk.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/uk.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/uk.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/uk.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/zh_cn.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/zh_cn.yml
similarity index 85%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/zh_cn.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/zh_cn.yml
index 1a5ce1d6..adc64b4b 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/zh_cn.yml
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/zh_cn.yml
@@ -14,8 +14,8 @@ zh_cn:
currency:
format:
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
- format: "%u %n"
- unit: "元"
+ format: "%u%n"
+ unit: "RMB"
# These three are to override number.format and are optional
separator: "."
delimiter: ","
@@ -50,12 +50,12 @@ zh_cn:
format: "%n %u"
units:
byte:
- one: "Byte"
- other: "Bytes"
- kb: "KB"
- mb: "MB"
- gb: "GB"
- tb: "TB"
+ one: "字节"
+ other: "字节"
+ kb: "K"
+ mb: "兆"
+ gb: "G"
+ tb: "T"
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime:
@@ -92,13 +92,12 @@ zh_cn:
one: "一年多"
other: "%{count} 年多"
almost_x_years:
- one: "接近一年"
- other: "接近 %{count} 年"
+ one: "已经一年"
+ other: "已经 %{count} 年"
models:
errors:
template:
header:
- one: "有1 个错误发生使得「%{model}」无法被储存。 "
- other: "有%{count} 个错误发生使得「%{model}」无法被储存。 "
- body: "以下栏位发生问题:"
-
+ one: "%{model} 保存时产生错误"
+ other: "%{model} 保存时产生了 %{count} 个错误"
+ body: "下列字段产生错误:"
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/zh_tw.yml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/zh_tw.yml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/locale/zh_tw.yml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/locale/zh_tw.yml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/number_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/number_helpers.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/number_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/number_helpers.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers.rb
similarity index 77%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers.rb
index 792eaf5c..de1df3d1 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers.rb
@@ -26,6 +26,8 @@ module Padrino
##
# Captures the html from a block of template code for any available handler.
#
+ # Be aware that trusting the html is up to the caller.
+ #
# @param [Object] *args
# Objects yield to the captured block
# @param [Proc] &block
@@ -37,15 +39,21 @@ module Padrino
# capture_html(&block) => "...html..."
# capture_html(object_for_block, &block) => "...html..."
#
+ # @example
+ # ActiveSupport::SafeBuffer.new + capture_html { "" }
+ # # => "<foo>"
+ # ActiveSupport::SafeBuffer.safe_concat + capture_html { "" }
+ # # => ""
+ #
# @api semipublic
def capture_html(*args, &block)
handler = find_proper_handler
- captured_html = ""
+ captured_block, captured_html = nil, ""
if handler && handler.is_type? && handler.block_is_type?(block)
- captured_html = handler.capture_from_template(*args, &block)
+ captured_html, captured_block = handler.capture_from_template(*args, &block)
end
# invoking the block directly if there was no template
- captured_html = block_given? && block.call(*args) if captured_html.blank?
+ captured_html = block_given? && ( captured_block || block.call(*args) ) if captured_html.blank?
captured_html
end
alias :capture :capture_html
@@ -53,7 +61,9 @@ module Padrino
##
# Outputs the given text to the templates buffer directly.
#
- # @param [String] text
+ # The output might be subject to escaping, if it is not marked as safe.
+ #
+ # @param [String,SafeBuffer] text
# Text to concatenate to the buffer.
#
# @example
@@ -70,6 +80,21 @@ module Padrino
end
alias :concat :concat_content
+ ##
+ # Outputs the given text to the templates buffer directly,
+ # assuming that it is safe.
+ #
+ # @param [String] text
+ # Text to concatenate to the buffer.
+ #
+ # @example
+ # concat_safe_content("This will be output to the template buffer")
+ #
+ # @api semipublic
+ def concat_safe_content(text="")
+ concat_content text.html_safe
+ end
+
##
# Returns true if the block is from a supported template type; false otherwise.
# Used to determine if html should be returned or concatenated to the view.
@@ -146,7 +171,7 @@ module Padrino
def yield_content(key, *args)
blocks = content_blocks[key.to_sym]
return nil if blocks.empty?
- blocks.map { |content| capture_html(*args, &content) }.join
+ mark_safe(blocks.map { |content| capture_html(*args, &content) }.join)
end
protected
@@ -170,6 +195,21 @@ module Padrino
def find_proper_handler
OutputHelpers.handlers.map { |h| h.new(self) }.find { |h| h.engines.include?(current_engine) && h.is_type? }
end
+
+ ##
+ # Marks a String or a collection of Strings as safe. `nil` is accepted
+ # but ignored.
+ #
+ # @param [String, Array] the values to be marked safe.
+ #
+ # @return [ActiveSupport::SafeBuffer, Array]
+ def mark_safe(value)
+ if value.respond_to? :map!
+ value.map!{|v| v.html_safe if v }
+ else
+ value.html_safe if value
+ end
+ end
end # OutputHelpers
end # Helpers
end # Padrino
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/abstract_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/abstract_handler.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/erb_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/erb_handler.rb
similarity index 92%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/erb_handler.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/erb_handler.rb
index f40cf715..72703719 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/erb_handler.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/erb_handler.rb
@@ -28,11 +28,11 @@ module Padrino
# @handler.capture_from_template(&block) => "...html..."
#
def capture_from_template(*args, &block)
- self.output_buffer, _buf_was = "", self.output_buffer
- block.call(*args)
+ self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer
+ captured_block = block.call(*args)
ret = eval("@_out_buf", block.binding)
self.output_buffer = _buf_was
- ret
+ [ ret, captured_block ]
end
##
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/haml_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/haml_handler.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/slim_handler.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb
similarity index 85%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/slim_handler.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb
index 798ea922..91baa672 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/output_helpers/slim_handler.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb
@@ -1,5 +1,4 @@
# Make slim works with sinatra/padrino
-Slim::Engine.set_default_options(:buffer => '@_out_buf', :generator => Temple::Generators::StringBuffer) if defined?(Slim)
module Padrino
module Helpers
@@ -31,11 +30,11 @@ module Padrino
# @handler.capture_from_template(&block) => "...html..."
#
def capture_from_template(*args, &block)
- self.output_buffer, _buf_was = '', self.output_buffer
- block.call(*args)
- ret = eval('@_out_buf', block.binding)
+ self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer
+ captured_block = block.call(*args)
+ ret = eval("@_out_buf", block.binding)
self.output_buffer = _buf_was
- ret
+ [ ret, captured_block ]
end
##
@@ -73,9 +72,9 @@ module Padrino
def output_buffer=(val)
template.instance_variable_set(:@_out_buf, val)
end
- end # SlimHandler
+ end # SlimHandler
- OutputHelpers.register(SlimHandler)
+ OutputHelpers.register(SlimHandler)
end # OutputHelpers
end # Helpers
end # Padrino
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/render_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/render_helpers.rb
similarity index 95%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/render_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/render_helpers.rb
index f51bc94f..a465db51 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/render_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/render_helpers.rb
@@ -46,12 +46,12 @@ module Padrino
counter += 1
options[:locals].merge!(object_name => member, "#{object_name}_counter".to_sym => counter)
render(explicit_engine, template_path, options.dup)
- }.join("\n")
+ }.join("\n").html_safe
else
if member = options.delete(:object)
options[:locals].merge!(object_name => member)
end
- render(explicit_engine, template_path, options.dup)
+ render(explicit_engine, template_path, options.dup).html_safe
end
end
alias :render_partial :partial
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/tag_helpers.rb
similarity index 88%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/tag_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/tag_helpers.rb
index e89dba68..29f714d8 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/tag_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/tag_helpers.rb
@@ -13,6 +13,12 @@ module Padrino
'"' => """
}
+ ##
+ # Cached Regexp for escaping values to avoid rebuilding one
+ # on every escape operation.
+ #
+ ESCAPE_REGEXP = Regexp.union(*ESCAPE_VALUES.keys)
+
BOOLEAN_ATTRIBUTES = [
:autoplay,
:autofocus,
@@ -42,6 +48,12 @@ module Padrino
:confirm
]
+ ##
+ # A html_safe newline string to avoid allocating a new on each
+ # concatenation.
+ #
+ NEWLINE = "\n".html_safe.freeze
+
##
# Creates an HTML tag with given name, content, and options
#
@@ -104,14 +116,30 @@ module Padrino
content = capture_html(&block)
end
- content = content.join("\n") if content.respond_to?(:join)
-
options = parse_data_options(name, options)
attributes = tag_attributes(options)
- output = "<#{name}#{attributes}>#{content}#{name}>"
+ output = ActiveSupport::SafeBuffer.new
+ output.safe_concat "<#{name}#{attributes}>"
+ if content.respond_to?(:each) && !content.is_a?(String)
+ content.each { |c| output.concat c; output.safe_concat NEWLINE }
+ else
+ output.concat content
+ end
+ output.safe_concat "#{name}>"
+
block_is_template?(block) ? concat_content(output) : output
end
+ ##
+ # Like #content_tag, but assumes its input to be safe and doesn't
+ # escape. It also returns safe html.
+ #
+ # @see #content_tag
+ #
+ def safe_content_tag(name, content = nil, options = nil, &block)
+ mark_safe(content_tag(name, mark_safe(content), options, &block))
+ end
+
##
# Creates an HTML input field with the given type and options
#
@@ -185,7 +213,7 @@ module Padrino
#
# @example
# tag :hr, :class => 'dotted'
- # # =>
+ # # =>
#
# tag :input, :name => 'username', :type => :text
# # =>
@@ -200,7 +228,7 @@ module Padrino
def tag(name, options = nil, open = false)
options = parse_data_options(name, options)
attributes = tag_attributes(options)
- "<#{name}#{attributes}#{open ? '>' : ' />'}"
+ "<#{name}#{attributes}#{open ? '>' : ' />'}".html_safe
end
private
@@ -226,7 +254,7 @@ module Padrino
# Escape tag values to their HTML/XML entities.
##
def escape_value(string)
- string.to_s.gsub(Regexp.union(*ESCAPE_VALUES.keys)) { |c| ESCAPE_VALUES[c] }
+ string.to_s.gsub(ESCAPE_REGEXP) { |c| ESCAPE_VALUES[c] }
end
##
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/translation_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/translation_helpers.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/lib/padrino-helpers/translation_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/translation_helpers.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/padrino-helpers.gemspec b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/padrino-helpers.gemspec
old mode 100755
new mode 100644
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/padrino-helpers.gemspec
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/padrino-helpers.gemspec
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/app.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/app.rb
similarity index 65%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/app.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/app.rb
index 6c44f893..cbbf5b5e 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/app.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/app.rb
@@ -2,12 +2,19 @@ require 'sinatra/base'
require 'haml'
require 'erubis'
require 'slim'
+require 'padrino-core/application/rendering/extensions/erubis'
+require 'padrino-core/application/rendering/extensions/haml'
+require 'padrino-core/application/rendering/extensions/slim'
class MarkupDemo < Sinatra::Base
register Padrino::Helpers
configure do
set :root, File.dirname(__FILE__)
+ set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
+ set :haml, :escape_html => true
+ set :slim, :generator => Temple::Generators::RailsOutputBuffer,
+ :buffer => "out_buf"
end
get '/:engine/:file' do
@@ -23,19 +30,19 @@ class MarkupDemo < Sinatra::Base
def captured_content(&block)
content_html = capture_html(&block)
- "
#{content_html}
"
+ "
#{content_html}
".html_safe
end
def concat_in_p(content_html)
- concat_content "
#{content_html}
"
+ concat_safe_content "
#{content_html}
"
end
- def determine_block_is_template(name, &block)
- concat_content "
The #{name} block passed in is a template
" if block_is_template?(block)
+ def concat_if_block_is_template(name, &block)
+ concat_safe_content "
The #{name} block passed in is a template
" if block_is_template?(block)
end
- def ruby_not_template_block
- determine_block_is_template('ruby') do
+ def concat_ruby_not_template_block
+ concat_if_block_is_template('ruby') do
content_tag(:span, "This not a template block")
end
end
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.erb
similarity index 73%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.erb
index 395536ad..220cbd4e 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.erb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.erb
@@ -6,9 +6,9 @@
<% concat_in_p('Concat Line 3') %>
-<% determine_block_is_template('erb') do %>
+<% concat_if_block_is_template('erb') do %>
This is erbThis is erb
<% end %>
-<% ruby_not_template_block %>
+<% concat_ruby_not_template_block %>
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.haml
similarity index 69%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.haml
index 54831676..527c0115 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.haml
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.haml
@@ -5,8 +5,8 @@
- concat_in_p('Concat Line 3')
-- determine_block_is_template('haml') do
+- concat_if_block_is_template('haml') do
%span This is haml
%span This is haml
-- ruby_not_template_block
+- concat_ruby_not_template_block
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.slim
similarity index 51%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.slim
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.slim
index ffef5e00..04186e7b 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/capture_concat.slim
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/capture_concat.slim
@@ -1,13 +1,12 @@
- @content = captured_content do
span Captured Line 1
span Captured Line 2
+= @content
-== @content
+- concat_in_p('Concat Line 3')
-- determine_block_is_template('slim') do
+- concat_if_block_is_template('slim') do
span This is slim
span This is slim
-== concat_in_p('Concat Line 3')
-
-== ruby_not_template_block
+- concat_ruby_not_template_block
\ No newline at end of file
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.slim
similarity index 53%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.slim
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.slim
index f6e6770d..be66c854 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_for.slim
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_for.slim
@@ -1,12 +1,12 @@
- content_for :demo do
h1 This is content yielded from a content_for
-.demo== yield_content :demo
+.demo= yield_content :demo
- content_for :demo2 do |fname, lname|
h1 This is content yielded with name #{fname + " " + lname}
-.demo2== yield_content :demo2, "Johnny", "Smith"
+.demo2= yield_content :demo2, "Johnny", "Smith"
-.demo_has_content== content_for?(:demo)
-.fake_has_content== content_for?(:fake)
\ No newline at end of file
+.demo_has_content= content_for?(:demo)
+.fake_has_content= content_for?(:fake)
\ No newline at end of file
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_tag.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_tag.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.slim
new file mode 100644
index 00000000..5ba06188
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.slim
@@ -0,0 +1,9 @@
+=content_tag :p, "Test 1", :class => 'test', :id => "test1"
+
+=content_tag :p, "Test 2"
+
+=content_tag(:p, :class => 'test', :id => 'test3') do
+ span Test 3
+
+=content_tag(:p) do
+ span Test 4
\ No newline at end of file
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.haml
similarity index 78%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.haml
index 3522395c..e7498a43 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.haml
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.haml
@@ -1,5 +1,5 @@
%p.start= current_engine
%p.haml= haml :'partials/_haml'
-%p.erb= erb :'partials/_erb'
+%p.erb= erb :'partials/_erb'
%p.slim= slim :'partials/_slim'
%p.end= current_engine
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.slim
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/current_engine.slim
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/current_engine.slim
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/fields_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/fields_for.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/fields_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/fields_for.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.slim
new file mode 100644
index 00000000..9046b11c
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.slim
@@ -0,0 +1,15 @@
+- @user = MarkupUser.new
+= form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
+ = f.text_field :gender
+ = fields_for @user.permission do |permission|
+ = permission.check_box :can_edit
+ = permission.check_box :can_delete
+ = f.fields_for :telephone do |child_form|
+ = child_form.label :number
+ = child_form.text_field :number
+ = f.fields_for :addresses do |child_form|
+ = child_form.label :name
+ = child_form.text_field :name
+ - unless child_form.object.new_record?
+ = child_form.check_box '_destroy'
+ = child_form.label '_destroy', :caption => 'Remove'
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_for.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_for.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_for.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_for.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.slim
new file mode 100644
index 00000000..cf0ad875
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.slim
@@ -0,0 +1,59 @@
+= form_for MarkupUser.new, '/demo', :id => 'demo' do |f|
+ = f.error_messages(:header_message => "custom MarkupUser cannot be saved!")
+ = f.hidden_field :session_id
+ p
+ = f.label :username, :caption => "Login: ", :class => 'user-label'
+ = f.text_field :username, :class => 'user-text', :value => "John"
+ p
+ = f.label :password
+ = f.password_field :password, :class => 'user-password', :value => "secret"
+ p
+ = f.label :age
+ = f.number_field :age, :class => 'numeric'
+ p
+ = f.label :telephone
+ = f.telephone_field :telephone, :class => 'numeric'
+ p
+ = f.label :email, :caption => 'Email Address: '
+ = f.email_field :email, :class => 'string'
+ p
+ = f.label :webpage, :caption => 'Your Web Page: '
+ = f.url_field :webpage, :class => 'string'
+ p
+ = f.label :search
+ = f.search_field :search, :class => 'string'
+ p
+ = f.label :photo
+ = f.file_field :photo, :class => 'user-photo'
+ p
+ = f.label :about, :caption => "About Me: "
+ = f.text_area :about, :class => 'user-about'
+ p
+ = f.label :gender, :caption => "Your gender: "
+ = f.radio_button :gender, :value => 'male'
+ = f.radio_button :gender, :value => 'female'
+ p
+ = f.label :country, :caption => "Your country"
+ = f.select :country, :options => ['USA', 'Canada', 'Mexico'], :selected => 'USA', :class => 'selector'
+ p
+ = f.label :remember_me
+ = f.check_box :remember_me, :value => "1"
+ p
+ = f.submit "Create", :class => 'success', :id => 'demo-button'
+ p
+ = f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button'
+
+= form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f|
+ = f.error_messages :header_message => "custom MarkupUser cannot be saved!"
+ = f.hidden_field :session_id
+ = f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' }
+ = f.password_field_block :code, { :class => 'input' }
+ = f.text_area_block :about, { :class => 'textarea' }
+ = f.file_field_block :photo, { :class => 'upload' }
+ = f.check_box_block :remember_me, { :class => 'checker' }
+ = f.select_block :state, :options => ['California', 'Texas'], :class => 'selector'
+ = f.submit_block "Create", { :class => 'button' }
+ = f.image_submit_block "buttons/ok.png", { :class => 'image' }
+
+= form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f|
+ = f.text_field_block :username
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_tag.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_tag.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.slim
new file mode 100644
index 00000000..053097bf
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.slim
@@ -0,0 +1,70 @@
+= form_tag '/simple', :class => 'simple-form' do
+ = error_messages_for nil
+ = field_set_tag do
+ = hidden_field_tag :session_id, :value => "__secret__"
+ = label_tag :username
+ = text_field_tag :username
+ = label_tag :password
+ = password_field_tag :password
+ = label_tag :email
+ = email_field_tag :email
+ = label_tag :age
+ = number_field_tag :age
+ = label_tag :telephone
+ = telephone_field_tag :telephone
+ = label_tag :webpage
+ = url_field_tag :webpage
+ = label_tag :search
+ = search_field_tag :search
+ = label_tag :color
+ = select_tag :color, :options => ['green', 'orange', 'purple']
+ = label_tag :gender
+ = radio_button_tag :gender, :value => 'male'
+ = radio_button_tag :gender, :value => 'female'
+ = check_box_tag :remember_me
+ = submit_tag
+
+= form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do
+ = error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!"
+ = hidden_field_tag :session_id, :value => "__secret__"
+ = field_set_tag "Advanced", :class => 'advanced-field-set' do
+ p
+ = label_tag :username, :class => 'first', :caption => "Nickname"
+ = text_field_tag :username, :value => params[:username], :id => 'the_username'
+ p
+ = label_tag :password, :class => 'first'
+ = password_field_tag :password, :value => params[:password]
+ p
+ = label_tag :email, :caption => 'Email Address'
+ = email_field_tag :email, :class => 'string'
+ p
+ = label_tag :age, :class => 'age'
+ = number_field_tag :age, :class => 'numeric'
+ p
+ = label_tag :telephone, :class => 'telephone'
+ = telephone_field_tag :telephone, :class => 'numeric'
+ p
+ = label_tag :webpage, :caption => 'Your Home Page'
+ = url_field_tag :webpage, :class => 'string'
+ p
+ = label_tag :search
+ = search_field_tag :search, :class => 'string'
+ p
+ = label_tag :about, :class => 'about', :caption => "About Me"
+ = text_area_tag :about, :class => 'large'
+ p
+ = label_tag :gender, :class => 'gender'
+ = radio_button_tag :gender, :value => 'male', :checked => true
+ = radio_button_tag :gender, :value => 'female'
+ p
+ = label_tag :photo, :class => 'photo'
+ = file_field_tag :photo, :class => 'upload'
+ p
+ = label_tag :fav_color
+ = select_tag :fav_color, :options => [ ['green', '1'], ['orange', '2'], ['purple', '3'] ], :selected => '2'
+ p
+ = check_box_tag :remember_me, :value => "1", :checked => true
+ = field_set_tag(:class => 'buttons') do
+ = submit_tag "Login"
+ = button_tag "Cancel"
+ = image_submit_tag "buttons/submit.png"
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/link_to.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/link_to.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/link_to.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/link_to.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.slim
new file mode 100644
index 00000000..01392638
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.slim
@@ -0,0 +1,4 @@
+= link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1'
+
+= link_to("/test2", :class => 'test', :id => 'test2') do
+ span Test 2 With Block
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/mail_to.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/mail_to.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/mail_to.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/mail_to.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.slim
new file mode 100644
index 00000000..9a8e10f1
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.slim
@@ -0,0 +1,3 @@
+p.simple= mail_to 'test@demo.com'
+
+p.captioned= mail_to 'test@demo.com', "Click my Email"
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/meta_tag.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/meta_tag.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/meta_tag.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/meta_tag.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.slim
new file mode 100644
index 00000000..9ed5ae35
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.slim
@@ -0,0 +1,3 @@
+= meta_tag "weblog,news", :name => "keywords"
+
+= meta_tag "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/partials/_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_erb.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/partials/_erb.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_erb.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/partials/_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_haml.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/partials/_haml.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_haml.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_slim.slim
new file mode 100644
index 00000000..839716be
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_slim.slim
@@ -0,0 +1 @@
+= current_engine
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/simple_partial.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/simple_partial.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/simple_partial.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/simple_partial.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.slim
new file mode 100644
index 00000000..ca16c418
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.slim
@@ -0,0 +1 @@
+p.slim= partial 'partials/slim', :engine => "slim"
\ No newline at end of file
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/app.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/app.rb
similarity index 83%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/app.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/app.rb
index 809bf766..9d492e46 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/app.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/app.rb
@@ -16,6 +16,9 @@ class RenderDemo < Padrino::Application
configure do
set :logging, false
set :padrino_logging, false
+ set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
+ set :haml, :escape_html => true
+ set :slim, :generator => Temple::Generators::RailsOutputBuffer
end
# get current engines from partials
@@ -28,6 +31,10 @@ class RenderDemo < Padrino::Application
render :explicit_engine
end
+ get '/double_capture_:ext' do
+ render "double_capture_#{params[:ext]}"
+ end
+
# partial with object
get '/partial/object' do
partial 'template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engine.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engine.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engine.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_erb.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_erb.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_erb.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_haml.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_haml.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_haml.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_slim.slim
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/current_engines/_slim.slim
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/current_engines/_slim.slim
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_erb.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_erb.erb
new file mode 100644
index 00000000..c7f7e123
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_erb.erb
@@ -0,0 +1,3 @@
+<% form_for( :object, '/' ) do |f| %>
+ <%= $number_of_captures += 1 %>
+<% end %>
\ No newline at end of file
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_haml.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_haml.haml
new file mode 100644
index 00000000..26102762
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_haml.haml
@@ -0,0 +1,2 @@
+- form_for :object, '/' do |f|
+ = $number_of_captures += 1
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_slim.slim b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_slim.slim
new file mode 100644
index 00000000..26102762
--- /dev/null
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_slim.slim
@@ -0,0 +1,2 @@
+- form_for :object, '/' do |f|
+ = $number_of_captures += 1
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/erb/test.erb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/erb/test.erb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/erb/test.erb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/erb/test.erb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/explicit_engine.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/explicit_engine.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/explicit_engine.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/explicit_engine.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/haml/test.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/haml/test.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/haml/test.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/haml/test.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/_user.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/_user.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/_user.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/_user.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/haml_template.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/haml_template.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/haml_template.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/haml_template.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/some_template.haml b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/some_template.haml
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/render_app/views/template/some_template.haml
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/template/some_template.haml
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/helper.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/helper.rb
similarity index 97%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/helper.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/helper.rb
index b1452e6d..9038f4ea 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/helper.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/helper.rb
@@ -27,6 +27,7 @@ class MiniTest::Spec
# In this case, block is the html to evaluate
def assert_has_tag(name, attributes = {}, &block)
html = block && block.call
+ assert html.html_safe?, 'html_safe? failed'
matcher = HaveSelector.new(name, attributes)
raise "Please specify a block!" if html.blank?
assert matcher.matches?(html), matcher.failure_message
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_asset_tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_asset_tag_helpers.rb
similarity index 93%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_asset_tag_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_asset_tag_helpers.rb
index 594be5b8..d0c196b2 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_asset_tag_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_asset_tag_helpers.rb
@@ -23,7 +23,7 @@ describe "AssetTagHelpers" do
should "display multiple flash tags with given attributes" do
flash[:error] = 'wrong'
flash[:success] = 'okey'
- actual_html = flash_tag(:success, :error, :id => 'area')
+ actual_html = flash_tag(:success, :warning, :error, :id => 'area')
assert_has_tag('div.success#area', :content => flash[:success]) { actual_html }
assert_has_tag('div.error#area', :content => flash[:error]) { actual_html }
assert_has_no_tag('div.notice') { actual_html }
@@ -70,6 +70,17 @@ describe "AssetTagHelpers" do
assert_has_tag('a#binky.first', :content => "Sign up", :href => '/register') { actual_link }
end
+ should "escape the link text" do
+ actual_link = link_to('/register', :class => 'first', :id => 'binky') { "<>" }
+ assert_has_tag('a#binky.first', :href => '/register') { actual_link }
+ assert_match "<>", actual_link
+ end
+
+ should "not escape image_tag" do
+ actual_link = link_to(image_tag("/my/fancy/image.png"), :class => 'first', :id => 'binky')
+ assert_has_tag('img', :src => "/my/fancy/image.png") { actual_link }
+ end
+
should "display link block element in haml" do
visit '/haml/link_to'
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
@@ -183,16 +194,15 @@ describe "AssetTagHelpers" do
should "display image tag relative link with incorrect spacing" do
time = stop_time_for_test
assert_has_tag('img.photo', :src => "/images/%20relative/%20pic.gif%20%20?#{time.to_i}") {
- image_tag(' relative/ pic.gif ', :class => 'photo') }
+ image_tag(' relative/ pic.gif ', :class => 'photo')
+ }
end
should "not use a timestamp if stamp setting is false" do
- self.class.expects(:asset_stamp).returns(false)
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
end
should "have xhtml convention tag" do
- self.class.expects(:asset_stamp).returns(false)
assert_equal image_tag('/absolute/pic.gif'), ''
end
end
@@ -200,8 +210,10 @@ describe "AssetTagHelpers" do
context 'for #stylesheet_link_tag method' do
should "display stylesheet link item" do
time = stop_time_for_test
+ actual_html = stylesheet_link_tag('style')
expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
- assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}")) { stylesheet_link_tag('style') }
+ assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}")) { actual_html }
+ assert actual_html.html_safe?
end
should "display stylesheet link item for long relative path" do
@@ -248,6 +260,7 @@ describe "AssetTagHelpers" do
time = stop_time_for_test
actual_html = javascript_include_tag('application')
assert_has_tag('script', :src => "/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ assert actual_html.html_safe?
end
should "display javascript item for long relative path" do
@@ -281,6 +294,12 @@ describe "AssetTagHelpers" do
assert_has_tag('script', :src => "/blog/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
end
+ should "not append extension to absolute paths" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('https://maps.googleapis.com/maps/api/js?key=value&sensor=false')
+ assert_has_tag('script', :src => "https://maps.googleapis.com/maps/api/js?key=value&sensor=false") { actual_html }
+ end
+
should "display javascript items" do
time = stop_time_for_test
actual_html = javascript_include_tag('application', 'base.js', 'http://google.com/lib.js')
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_builder.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_builder.rb
similarity index 95%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_builder.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_builder.rb
index b3cdb744..6b462312 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_builder.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_builder.rb
@@ -20,7 +20,7 @@ describe "FormBuilder" do
mock_model('Role', :name => 'Moderate', :id => 2), mock_model('Role', :name => 'Limited', :id => 3)]
@user = mock_model("User", :first_name => "Joe", :email => '', :session_id => 54)
@user.stubs(:errors => {:a => "must be present", :b => "must be valid", :email => "Must be valid", :first_name => []})
- @user.stubs(:role_types => role_types, :role => "1")
+ @user.stubs(:role_types => role_types, :role => "1", :roles => [1,3])
@user_none = mock_model("User")
end
@@ -103,6 +103,7 @@ describe "FormBuilder" do
assert_have_selector :form, :action => '/demo', :id => 'demo'
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
should "display correct form in erb" do
@@ -110,6 +111,7 @@ describe "FormBuilder" do
assert_have_selector :form, :action => '/demo', :id => 'demo'
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
should "display correct form in slim" do
@@ -117,6 +119,7 @@ describe "FormBuilder" do
assert_have_selector :form, :action => '/demo', :id => 'demo'
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
should "have a class of 'invalid' for fields with errors" do
@@ -253,6 +256,12 @@ describe "FormBuilder" do
assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
end
+ should "set specific content inside the label if a block was provided" do
+ actual_html = standard_builder.label(:admin, :class => 'large') { input_tag :checkbox }
+ assert_has_tag('label', :class => 'large', :for => 'user_admin', :content => "Admin: ") { actual_html }
+ assert_has_tag('label input[type=checkbox]') { actual_html }
+ end
+
should "display correct label in haml" do
visit '/haml/form_for'
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
@@ -492,6 +501,37 @@ describe "FormBuilder" do
end
end
+ context 'for #check_box_group and #radio_button_group methods' do
+ should 'display checkbox group html' do
+ checkboxes = standard_builder.check_box_group(:role, :collection => @user.role_types, :fields => [:name, :id], :selected => [2,3])
+ assert_has_tag('input[type=checkbox]', :value => '1') { checkboxes }
+ assert_has_no_tag('input[type=checkbox][checked]', :value => '1') { checkboxes }
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :value => '2') { checkboxes }
+ assert_has_tag('label[for=user_role_3] input[name="user[role][]"][value="3"][checked]') { checkboxes }
+ end
+
+ should 'display checkbox group html and extract selected values from the object' do
+ checkboxes = standard_builder.check_box_group(:roles, :collection => @user.role_types, :fields => [:name, :id])
+ assert_has_tag('input[type=checkbox][name="user[roles][]"][value="1"][checked]') { checkboxes }
+ assert_has_tag('input[type=checkbox][name="user[roles][]"][value="3"][checked]') { checkboxes }
+ assert_has_no_tag('input[type=checkbox][name="user[roles][]"][value="2"][checked]') { checkboxes }
+ end
+
+ should 'display radio group html' do
+ radios = standard_builder.radio_button_group(:role, :options => %W(red yellow blue), :selected => 'yellow')
+ assert_has_tag('input[type=radio]', :value => 'red') { radios }
+ assert_has_no_tag('input[type=radio][checked]', :value => 'red') { radios }
+ assert_has_tag('input[type=radio]', :checked => 'checked', :value => 'yellow') { radios }
+ assert_has_tag('label[for=user_role_blue] input[name="user[role]"][value=blue]') { radios }
+ end
+
+ should 'display radio group html and extract selected value from the object' do
+ radios = standard_builder.radio_button_group(:role, :collection => @user.role_types)
+ assert_has_tag('input[type=radio][value="1"][checked]') { radios }
+ assert_has_no_tag('input[type=radio][value="2"][checked]') { radios }
+ end
+ end
+
context 'for #radio_button method' do
should "display correct radio button html" do
actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_helpers.rb
similarity index 95%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_helpers.rb
index 8cf3f891..5662c07f 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_form_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_form_helpers.rb
@@ -58,18 +58,21 @@ describe "FormHelpers" do
visit '/erb/form_tag'
assert_have_selector 'form.simple-form', :action => '/simple'
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
should "display correct forms in haml" do
visit '/haml/form_tag'
assert_have_selector 'form.simple-form', :action => '/simple'
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
should "display correct forms in slim" do
visit '/slim/form_tag'
assert_have_selector 'form.simple-form', :action => '/simple'
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ assert_have_selector :input, :name => 'authenticity_token'
end
end
@@ -197,6 +200,12 @@ describe "FormHelpers" do
assert_has_tag('label[for=username] span.required', :content => "*") { actual_html }
end
+ should "display label tag in ruby with a block" do
+ actual_html = label_tag(:admin, :class => 'long-label') { input_tag :checkbox }
+ assert_has_tag(:label, :for => 'admin', :class => 'long-label', :content => "Admin") { actual_html }
+ assert_has_tag('label input[type=checkbox]') { actual_html }
+ end
+
should "display label tag in erb for simple form" do
visit '/erb/form_tag'
assert_have_selector 'form.simple-form label', :count => 9
@@ -204,6 +213,7 @@ describe "FormHelpers" do
assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
end
+
should "display label tag in erb for advanced form" do
visit '/erb/form_tag'
assert_have_selector 'form.advanced-form label', :count => 11
@@ -484,6 +494,11 @@ describe "FormHelpers" do
assert_has_tag(:input, :type => 'file', :class => "photo", :name => 'photo') { actual_html }
end
+ should "have an array name with multiple option" do
+ actual_html = file_field_tag(:photos, :multiple => true)
+ assert_has_tag(:input, :name => 'photos[]') { actual_html }
+ end
+
should "display file field in erb" do
visit '/erb/form_tag'
assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
@@ -773,4 +788,25 @@ describe "FormHelpers" do
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
end
end
+
+ context 'for #button_to method' do
+ should "have a form and set the method properly" do
+ actual_html = button_to('Delete', '/users/1', :method => :delete)
+ assert_has_tag('form', :action => '/users/1') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "authenticity_token") { actual_html }
+ end
+
+ should "add a submit button by default if no content is specified" do
+ actual_html = button_to('My Delete Button', '/users/1', :method => :delete)
+ assert_has_tag('form input', :type => 'submit', :value => 'My Delete Button') { actual_html }
+ end
+
+ should "set specific content inside the form if a block was sent" do
+ actual_html = button_to('My Delete Button', '/users/1', :method => :delete) do
+ content_tag :button, "My button's content", :type => :submit, :title => "My button"
+ end
+ assert_has_tag('form button', :type => 'submit', :content => "My button's content", :title => "My button") { actual_html }
+ end
+ end
end
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_format_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_format_helpers.rb
similarity index 91%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_format_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_format_helpers.rb
index 19e9c5ed..8f107719 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_format_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_format_helpers.rb
@@ -15,6 +15,7 @@ describe "FormatHelpers" do
context 'for #simple_format method' do
should "format simple text into html format" do
actual_text = simple_format("Here is some basic text...\n...with a line break.")
+ assert_equal true, actual_text.html_safe?
assert_equal "
Here is some basic text...\n ...with a line break.
", actual_text
end
@@ -139,6 +140,11 @@ describe "FormatHelpers" do
should "return text escaped if not empty" do
assert_equal '<h1>hello</h1>', h!('
hello
')
end
+ should "mark escaped text as safe" do
+ assert_equal false, '
hello
'.html_safe?
+ assert_equal true, h('
hello
').html_safe?
+ assert_equal true, h!("", "default").html_safe?
+ end
end
context 'for #time_ago_in_words method' do
@@ -213,15 +219,23 @@ describe "FormatHelpers" do
context 'for #js_escape_html method' do
should "escape double quotes" do
assert_equal "\\\"hello\\\"", js_escape_html('"hello"')
+ assert_equal "\\\"hello\\\"", js_escape_html(ActiveSupport::SafeBuffer.new('"hello"'))
end
should "escape single quotes" do
assert_equal "\\'hello\\'", js_escape_html("'hello'")
+ assert_equal "\\'hello\\'", js_escape_html(ActiveSupport::SafeBuffer.new("'hello'"))
end
should "escape html tags and breaks" do
assert_equal "\\n\\n
\r\n"))
end
should "escape data-confirm attribute" do
assert_equal "", js_escape_html("")
+ assert_equal "", js_escape_html(ActiveSupport::SafeBuffer.new(""))
+ end
+ should "keep html_safe content html_safe" do
+ assert_equal false, js_escape_html('"hello"').html_safe?
+ assert_equal true, js_escape_html(ActiveSupport::SafeBuffer.new('"hello"')).html_safe?
end
end
end
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_locale.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_locale.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_locale.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_locale.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_number_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_number_helpers.rb
similarity index 100%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_number_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_number_helpers.rb
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_output_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_output_helpers.rb
similarity index 94%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_output_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_output_helpers.rb
index 56973280..fe244835 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_output_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_output_helpers.rb
@@ -79,7 +79,8 @@ describe "OutputHelpers" do
should "work for slim templates" do
visit '/slim/capture_concat'
- assert_have_selector 'p', :content => "Concat Line 3", :count => 1
+ # TODO Get Slim concat working
+ # assert_have_selector 'p', :content => "Concat Line 3", :count => 1
end
end
@@ -97,9 +98,10 @@ describe "OutputHelpers" do
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
end
- should_eventually "work for slim templates" do
+ should "work for slim templates" do
visit '/slim/capture_concat'
- assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template'
+ # TODO Get Slim template detection working
+ # assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template'
assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
end
end
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_render_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_render_helpers.rb
similarity index 85%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_render_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_render_helpers.rb
index 68bc6538..49dafd83 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_render_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_render_helpers.rb
@@ -72,5 +72,23 @@ describe "RenderHelpers" do
assert_have_selector 'p.slim span', :content => "slim"
assert_have_selector 'p.end', :content => "haml"
end
+
+ should "capture slim template once and only once" do
+ $number_of_captures = 0
+ visit '/double_capture_slim'
+ assert_equal 1,$number_of_captures
+ end
+
+ should "capture haml template once and only once" do
+ $number_of_captures = 0
+ visit '/double_capture_haml'
+ assert_equal 1,$number_of_captures
+ end
+
+ should "capture erb template once and only once" do
+ $number_of_captures = 0
+ visit '/double_capture_erb'
+ assert_equal 1,$number_of_captures
+ end
end
end
diff --git a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_tag_helpers.rb b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_tag_helpers.rb
similarity index 90%
rename from middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_tag_helpers.rb
rename to middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_tag_helpers.rb
index 494d9d30..8c36956a 100644
--- a/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/test_tag_helpers.rb
+++ b/middleman-core/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/test_tag_helpers.rb
@@ -53,6 +53,17 @@ describe "TagHelpers" do
assert_has_tag('p.large#star', :content => "Demo") { actual_html }
end
+ should "escape non-html-safe content" do
+ actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
+ assert_has_tag('p.large#star') { actual_html }
+ assert_match('<>', actual_html)
+ end
+
+ should "not escape html-safe content" do
+ actual_html = content_tag(:p, :class => 'large', :id => 'star') { "<>" }
+ assert_has_tag('p.large#star', :content => "<>") { actual_html }
+ end
+
should "support tags with erb" do
visit '/erb/content_tag'
assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'