search_form.js 676 B

123456789101112
  1. 'use strict';
  2. function searchFormHelper(options = {}) {
  3. const config = this.config;
  4. const className = options.class || 'search-form';
  5. const text = options.hasOwnProperty('text') ? options.text : 'Search';
  6. const button = options.button;
  7. return `<form action="//google.com/search" method="get" accept-charset="UTF-8" class="${className}"><input type="search" name="q" class="${className}-input"${text ? ` placeholder="${text}"` : ''}>${button ? `<button type="submit" class="${className}-submit">${typeof button === 'string' ? button : text}</button>` : ''}<input type="hidden" name="sitesearch" value="${config.url}"></form>`;
  8. }
  9. module.exports = searchFormHelper;