Forme 2.0.0 Released #97
jeremyevans
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Backwards Compatibility
The internals of Forme::Form have been rewritten, and are not
completely backwards compatible. However, it is expected that the
changes made will not generally affect applications that use Forme,
though they can affect other libraries that use Forme. Any external
libraries that integrate Forme with other template engines will
probably need to be modified.
The main change compared to previous versions of Forme is that
Forme::Form now keeps a buffer of HTML generated by the form,
and methods such as #form, #input, #inputs, and #tag now return
strings of HTML for all HTML added by the method call. Template
integration is now handled via delegation instead of inheritance,
with significantly simpler and much more robust code.
When passing a callable object as the children of a tag, the
callable should return a child tag/input, it shouldn't directly
modify the form by calling #input, #inputs, or #tag on the related
Form.
Mutating the string returned by Forme::Form#to_s (which holds the
HTML buffer for the form) will cause future calls to #to_s to
return the mutated string.
The following Forme::Form methods have been removed, as they are
no longer necessary in the current version:
The Forme::Tag#<< method has also been removed.
The Forme::Form :hidden_tags option is now deprecated. Using the
option will result in a deprecation warning. All methods and
support for options related to hidden tags will be removed in Forme
2.1.0. Users of these options can switch to the new :before option
introduced in this version.
The forme/sinatra file and Forme::Sinatra::ERB constant is now
deprecated. Users should switch to forme/erb and Forme::ERB::Helper.
Support for forme/sinatra will be removed in Forme 2.1.0.
The _forme_form_options private method used in the template
integrations now accepts the object, attributes, and options instead
of just the options.
Support for Ruby 1.8.7 has been dropped. The minimum supported Ruby
version is now 1.9.2.
New Features
A Roda forme_erubi_capture plugin has been added to support the
use of forms in Roda when using the erubi/capture_end template
engine. This allows for the following API in templates:
Forme::Form now accepts :before and :after options. These accept
callables that will be called with the Form instance and can
add content to the form. This can be used to replace the
:hidden_tags option (which is now deprecated).
Forme::Form#form_tag_attributes has been added for getting the
attributes for the form tag. This method can only be called after
a call to #form.
Forme::Form#post? has been added for checking whether the form
will submit using the POST HTTP method. This method can only be
called after a call to #form.
Other Improvements
through the :errors option. It also supports the aria-invalid
and aria-describedby attributes.
Beta Was this translation helpful? Give feedback.
All reactions