2018-03-25 17:20:54 +00:00
|
|
|
<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%>
|
2018-03-25 17:30:42 +00:00
|
|
|
<%# use like this: render 'components/radio', label: 'Banana chips', name: 'fave_snacks' %>
|
|
|
|
<%# you can pass in an optional key for 'def'ing values to it %>
|
|
|
|
<%# if you have a set of radios, consider using components/_radio_set %>
|
|
|
|
|
|
|
|
<% value = label.downcase.tr(" ", "_") %>
|
|
|
|
<% id = "radio_#{name}_#{value}" %>
|
|
|
|
<% change ||= false %>
|
|
|
|
<% key ? change = "(def '#{key}' '#{value}')" : key = false %>
|
|
|
|
|
|
|
|
<input type="radio" id="<%= id %>" name="<%= name %>" value="<%= value %>">
|
|
|
|
<% if change %>
|
|
|
|
<!--= on 'change' <%= change.html_safe %> -->
|
|
|
|
<% end %>
|
|
|
|
<label for="<%= id %>"><%= label %></label>
|