Commit Graph

21 Commits

Author SHA1 Message Date
Rafael Mendonça França 0366830965 Rename to optional to unless_blank
optional may be confusing with the optional method
2014-06-23 16:11:35 -03:00
Ian Vaughan 21d03ff583 Only output the wrapper if the block yields content
This change allows the wrappers to not output their rendered HTML when
when the block yields no content.

e.g. when defining an optional component :

  ba.wrapper tag: :div, class: 'form-helper -message -hint' do |bb|
    bb.optional :hint, wrap_with: { tag: :p }
  end

and that component is not used in a template :

  <%= form.input :name %>

Then the HTML output still contains the wrapper output :

  <div class="form-helper -message -help"></div>

If this behaviour is not desired, then the output of the empty tags can
be disabled via the `remove_empty` option.

  ba.wrapper tag: :div, class: 'form-helper -message -hint', remove_empty: true do |bb|
    bb.optional :hint, wrap_with: { tag: :p }
  end

The above config will not output any wrapper HTML.
2014-05-29 10:25:16 +01:00
Rafael Mendonça França 3f47fd0d23 Merge remote-tracking branch 'origin/master' into rm-wrapper-classes
Conflicts:
	CHANGELOG.md
	lib/simple_form/inputs/boolean_input.rb
2014-03-14 18:59:40 -03:00
Rafael Mendonça França 58f14c3c92 Store the wrappers with string keys 2014-03-14 11:51:59 -03:00
Ulisses Herrera Freire de Almeida 862fab5681 Support additional attributes to custom wrapper tag.
We are using the html option on wrapper because the wrapper has some
options that are not related to html attributes.

Now you can for example:

```ruby
config.wrappers do |b|
  b.wrapper :tag => :td, :class => :some_class, :html => { :additional_html_attribute => :value }
end
```

Thanks @remofritzsche @rafaelfranca @bellthoven
2014-03-11 20:27:10 -03:00
Rafael Mendonça França 0fc7ea87da Update Many documentation 2014-03-11 19:52:05 -03:00
Rafael Mendonça França e9384fb4bd Whitespaces 2014-03-11 19:13:59 -03:00
Rafael Mendonça França 7a167ca65b Component alwyas respond to render now 2014-03-10 18:13:05 -03:00
Rafael Mendonça França 826841294f Deal only with objets in the Wrapper API 2014-03-10 18:06:55 -03:00
Remo Fritzsche f6a516cbf4 Possibility of specifying additional html attributes to 'wrap' 2013-10-03 15:10:10 +02:00
Rafael Mendonça França e147393d0f No need to call Array.wrap
Kernel#Array works very well
2012-12-13 14:03:17 -03:00
Rafael Mendonça França ba65e1c3b0 Fix namespace html propagation to single wrapper of label and input 2012-06-26 23:29:14 -03:00
José Valim b9a568d149 Ensure wrap_with without a tag works. 2012-02-18 15:47:02 +01:00
Rafael Mendonça França 8dc707a7c2 Add disabled class to disabled input 2011-09-11 18:46:47 -03:00
José Valim 1753926575 Support nested find. 2011-09-08 16:03:55 +02:00
José Valim b54110c935 Wrappers docs. 2011-09-08 16:03:27 +02:00
José Valim 1e91fb42c3 Do not use splat for clarity. 2011-09-08 16:03:27 +02:00
José Valim e34b6a6b4e Remove Symbol monkey patches. 2011-09-08 16:03:27 +02:00
José Valim f8a9bae534 Getting rid of the internal components option. 2011-09-08 16:03:26 +02:00
José Valim c6e6dbd62d Use the root wrapper and removing rendering responsibility from input. 2011-09-08 16:03:26 +02:00
José Valim f62667ce61 Let's call those thing wrappers. 2011-09-08 16:03:26 +02:00