Takes some markup of the form:
<div class="p-author h-card">
<div class="form-field">
<label for="p-first-name" class="required">First Name</label>
<input type="text" id="p-first-name" class="p-first-name" name="p-first-name" data-mapping="first_name" required>
</div>
<div class="form-field">
<label for="p-last-name" class="required">Last Name</label>
<input type="text" id="p-last-name" class="p-last-name" name="p-last-name" data-mapping="last_name" required>
</div>
</div>and returns an indifferent hash of the form:
{first_name: 'p-first-name', last_name: 'p-last-name'}Supports mapping multiple properties to the same form field
<div class="p-author h-card">
<div class="form-field">
<label for="p-first-name" class="required">First Name</label>
<input type="text" id="p-first-name" class="p-first-name" name="p-first-name" data-mapping="first_name billing_first_name" required>
</div> {first_name: 'p-first-name', billing_first_name: 'p-first-name'}Supports nested properties
<div class="p-author h-card">
<div class="form-field">
<label for="p-first-name" class="required">First Name</label>
<input type="text" id="p-first-name" class="p-first-name" name="p-first-name" data-mapping="customer[first_name]" required>
<input type="text" id="p-state" class="p-state" name="p-state" data-mapping="customer[address][state]" required>
</div> {customer: {first_name: 'p-first-name', address: {state: 'p-state'}}}Add this line to your application's Gemfile:
gem 'semantic-mapper'And then execute:
$ bundle
Or install it yourself as:
$ gem install semantic-mapper
TODO: Write usage instructions here
- Fork it ( https://github.com/[my-github-username]/semantic-mapper/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request