mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
6ef79534e4
Form: - add confirm, location & referrer hidden fields - add script to populate location & referrer - add helper for creating the email field - pass through input class and placeholder for email from top level form helper - rename subscribe_form template & helper as it sounds more natural - handle success and error cases differently - improve error message display - ensure useful data is passed back so that we can show nice messages - check for honeypot value being filled out - refactor error handler to set an error and always still render
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
// # Input Email Helper
|
|
// Usage: `{{input_email}}`
|
|
//
|
|
// Password input used on private.hbs for password-protected blogs
|
|
//
|
|
// We use the name meta_title to match the helper for consistency:
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
var hbs = require('express-hbs'),
|
|
utils = require('./utils'),
|
|
input_email;
|
|
|
|
input_email = function (options) {
|
|
options = options || {};
|
|
options.hash = options.hash || {};
|
|
|
|
var className = (options.hash.class) ? options.hash.class : 'subscribe-email',
|
|
extras = '',
|
|
output;
|
|
|
|
if (options.hash.autofocus) {
|
|
extras += 'autofocus="autofocus"';
|
|
}
|
|
|
|
if (options.hash.placeholder) {
|
|
extras += ' placeholder="' + options.hash.placeholder + '"';
|
|
}
|
|
|
|
if (options.hash.value) {
|
|
extras += ' value="' + options.hash.value + '"';
|
|
}
|
|
|
|
output = utils.inputTemplate({
|
|
type: 'email',
|
|
name: 'email',
|
|
className: className,
|
|
extras: extras
|
|
});
|
|
|
|
return new hbs.handlebars.SafeString(output);
|
|
};
|
|
|
|
module.exports = input_email;
|