Closed blelump closed 8 years ago
This is actually intentional to enable you to build your content without blocks.
The Container module provides an end method which gives you the closing tag.
I can see that being a pain when you want empty spans though.
Whilst I'm thinking, you could do this for now:
class Span < Formular::Elements::Container
tag :span
set_default :class, ['icon-controller-record']
self.html_context = :with_content
end
That forces your element to render the start & end tag regardless of content.
@fran-worley , fair enough for me ! Empty span
occurs due to the frontend design – it is a wrapper for radio checked/unchecked state (see image given in https://github.com/trailblazer/formular/issues/5 )
Yeah I've been thinking some more about this and am favouring rendering the complete 'empty' tag by default (most common use case) and providing a start method if you just want the opener. e.g.
# blockless example:
form = builder.form(action: '/questions/13')
html = form.start
html << form.textarea(:body).to_s
html << form.select(:public, collection: collection_array).to_s
html << form.input(:body).to_s
html << form.end
html.must_equal %(<form method="post" accept-charset=\"utf-8\" action="/questions/13"><input name=\"utf8\" type=\"hidden\" value=\"✓\"/><div class="form-group"><textarea name="comment[body]" id="comment_body" class="form-control">Something exciting</textarea></div><div class="form-group"><select name="comment[public]" id="comment_public" class="form-control"><option value="1">Yes</option><option value="0">No</option></select></div><div class="form-group"><input name="comment[body]" id="comment_body" value="Something exciting" type="text" class="form-control"/></div></form>)
Going to close this now as the default behaviour is no longer weird.
Hi @fran-worley ,
consider such class:
When rendered without any content, eg
Span.call()
it returns"<span class=\"icon-controller-record\">"
, whereasSpan.call(content: " ")
returns"<span class=\"icon-controller-record\"> </span>"
.