.try(() => {
   subject = _template(template.subject)(templateData)
   templateData.subject = subject
   templateData = formatContent(templateData)
   templateData._ = require('lodash')
   html = _template(template.html)(templateData)
   if (template.text) {
     text = _template(template.text)(templateData)
   }
 })
Beispiel #2
0
function template(url, ver, type, name) {
  if (name === 'larry' && type === 'moe') {
    return _template(url)({ version: ver, type: type + '_job_trigger_here' });
  } else if (name === 'curly') {
    return _template(url)({version: ver + '_BUILD/', type: type });
  } else if (name === 'EDD') {
    return _template(url)({ version: '', type: '' + 'artifact_handling_here/' });
  } else {
    return _template(url)({ version: ver, type: type });
  }
}
Beispiel #3
0
	_handleShare = () => {
		const {
			data,
			room,
			user,
		} = this.props;

		if (data && data.content) {
			try {
				Share.shareItem(data.title ? template(data.title)({ room, user }) : 'Share…', template(data.content)({ room, user }));
			} catch (e) {
				// ignore
			}
		}
	};
 .then(function () {
   var commitTemplate = fs.readFileSync(
     path.join(__dirname, '../utilities/INITIAL_COMMIT_MESSAGE.txt'));
   var commitMessage = template(commitTemplate)(pkg);
   return exec(
     'git commit -m "' + commitMessage + '"', { env: gitEnvironmentVariables });
 })
Beispiel #5
0
 .map(stockValue =>
     template(stockValueTemplate)({
         name: stockValue.name,
         deltaClass: `stocks__stock-value--${stockValue.trend}`,
         price: stockValue.price,
         change: deltaString(stockValue.change),
         closed: stockValue.closed
             ? '<div class="stocks__closed">closed</div>'
             : '',
         closedInline: stockValue.closed
             ? '<div class="stocks__closed--inline">closed</div>'
             : '',
         marketDownIcon: inlineSvg('marketDownIcon', [
             'stocks__icon',
             'stocks__icon--down',
         ]),
         marketUpIcon: inlineSvg('marketUpIcon', [
             'stocks__icon',
             'stocks__icon--up',
         ]),
         marketSameIcon: inlineSvg('marketSameIcon', [
             'stocks__icon',
             'stocks__icon--same',
         ]),
     })
Beispiel #6
0
function generateIndex(data, minify) {
    process.stdout.write('Generating index..\n');

    const tmpl = template(fs.readFileSync(`${projectDir}/web/.index.html`));
    let index;

    // Generate the index based on the template
    index = tmpl(data);

    // Minify the HTML
    if (minify) {
        index = minifyHtml(index, {
            removeComments: true,
            collapseWhitespace: true,
            conservativeCollapse: true,
            keepClosingSlash: true,
            minifyJS: true,
        });
    // Otherwise clean the empty lines left over from the template
    } else {
        index = index
            .split('\n')
            .filter((line) => !/^\s+$/.test(line))
            .join('\n');
    }

    fs.writeFileSync(`${projectDir}/web/index.html`, index);
}
Beispiel #7
0
const addTitleBar = (): void => {
    const data = {
        webTitle: config.get('page.webTitle'),
        pageId: config.get('page.pageId'),
        icon: inlineSvg('marque36icon'),
    };
    $('.vjs-control-bar').after(template(titlebarTmpl)(data));
};
Beispiel #8
0
function processTemplate(content, context) {
  var options = {
    evaluate:    /<%([\s\S]+?)%>/g,
    interpolate: /<%=([\s\S]+?)%>/g,
    escape:      /<%-([\s\S]+?)%>/g
  };
  return template(content, options)(context);
}
Beispiel #9
0
 render: function () {
     const html = template(viewTemplate)({
         // items: this.collection.models,
     });
     this.$el.append(html);
     styleHelper(this.el, styles);
     return this.$el;
 },
function compileTemplate(rawTemplate) {
	var compiledTemplate = template(rawTemplate);


	/* jshint validthis:true */
	// In this instance this has been bound by updateReadmeModules to be the contents of the cartridgeRc
	return compiledTemplate(this);
	/* jshint validthis:false */
}
Beispiel #11
0
		files.forEach((e:?ThreadTemplate) => {
			const id = uuid.v4();

			if (!e) return;
			changes.entities[id] = new Thread({
				id,
				type: TYPE_THREAD,
				name: template(e.title)({
					name: room.name
				}),
				body: template(e.body)({
					name: room.name
				}),
				tags: [ TAG_POST_AUTO_SEED ],
				parents: [ room.id ],
				creator: e.creator,
				createTime: Date.now(),
			});
		});
Beispiel #12
0
  /**
   * @param ruleObj
   * @param propertyName
   * @param val
   * @returns {String}
   */
  getValidationMessage(ruleObj, propertyName, val, inputObj) {
    const message = this.validation.messages[ruleObj.fullName];
    const messageTemplate = R.is(Function, message) ? message(ruleObj, propertyName, val) : message;
    const compiled = template(messageTemplate);
    propertyName = startCase(propertyName);

    return compiled({
      inputObj: inputObj,
      propertyName: propertyName,
      ruleName: ruleObj.fullName,
      ruleParams: ruleObj.params,
      value: val
    });
  }
Beispiel #13
0
const renderCampaign = (calloutNode: HTMLElement, calloutData): void => {
    const campaign = template(campaignForm)({ data: calloutData });
    const campaignDiv = `<figure class="element element-campaign">${campaign}</figure>`;

    fastdom
        .write(() => {
            calloutNode.innerHTML = campaignDiv;
        })
        .then(() => {
            const cForm = calloutNode.querySelector(
                '.element-campaign .campaign .campaign--snippet__body'
            );
            if (cForm) {
                cForm.addEventListener('submit', submitForm);
            }
        });
};
Beispiel #14
0
const renderAlert = (alert: Alert): bonzo => {
    alert.closeIcon = inlineSvg('closeCentralIcon');

    const $alert = bonzo.create(template(alertHtml)(alert));

    const closeButton = $('.js-breaking-news__item__close', $alert)[0];

    if (closeButton) {
        bean.on(closeButton, 'click', () => {
            fastdom.write(() => {
                $('[data-breaking-article-id]').hide();
            });
            markAlertAsDismissed(alert.id);
        });
    }

    return $alert;
};
Beispiel #15
0
    loadCssPromise.then(() => {
        const msg = new Message(messageCode, { position: 'top' });
        const fullTemplate = tmp + (getBreakpoint() === 'mobile' ? '' : tablet);

        msg.show(template(fullTemplate)(DATA[messageCode.toUpperCase()]));

        addCookie(COOKIE_IMPRESSION_KEY, String(impressions + 1));

        fastdom.read(() => {
            const $banner = $('.site-message--ios, .site-message--android');
            const bannerHeight = $banner.dim().height;
            if (window.scrollY !== 0) {
                window.scrollTo(window.scrollX, window.scrollY + bannerHeight);
            }
        });

        return true;
    });
Beispiel #16
0
    ]).then(([asyncEpicTests, asyncBannerTests]) => {
        const data = {
            testGroups: [
                {
                    name: 'Epic',
                    tests: [...asyncEpicTests, ...epicTests].map(extractData),
                },
                {
                    name: 'Banner',
                    tests: [...asyncBannerTests, ...engagementBannerTests].map(
                        extractData
                    ),
                },
                { name: 'Other', tests: concurrentTests.map(extractData) },
            ],
        };

        $('body').prepend(template(overlay)(data));
    });
Beispiel #17
0
	_handleView = async () => {
		const {
			room,
			user,
			data,
		} = this.props;

		if (data && data.url) {
			const link = template(data.url)({ room, user });

			try {
				const canOpen = await Linking.canOpenURL(link);

				if (canOpen) {
					await Linking.openURL(link);
				}
			} catch (e) {
				// ignore
			}
		}
	};
    transform: function transform(code, id) {
      if (!filter(id)) {
        return null;
      }

      if (! ~extensions.indexOf(extname(id))) {
        return null;
      }

      var tpl = template(code, templateOptions);

      var hasEscape = false;
      var source = tpl.source.replace(/__e = _.escape/, function () {
        hasEscape = true;
        return '__e = escape';
      });

      var intro = hasEscape ? "import escape from 'underscore'" : "";

      return '\n      ' + intro + '\n      export default ' + source + '\n      ';
    }
Beispiel #19
0
    const htmlLazyLoaderTemplate = require('roderic/libs/fileLazyLoader')(path.resolve(configWebpack.app, '..', 'index.html'), 30, (content, file) => {

        let tmp = replace(content, {
            file: configWebpack.server.timejs,
            isProd,
        });

        try {
            tmp = template(tmp);
        }
        catch (e) {

            throw `binding template '${file}' error, probably syntax error`;
        }

        return params => {
            try {
                return tmp(params);
            }
            catch (e) {
                tlog(`parsing template '${file}' error: `, e);
            }
        }
    });
Beispiel #20
0
import isArray from 'lodash/isArray';
import merge from 'lodash/merge';
import template from 'lodash/template';
import {readFileSync} from 'fs';
import {resolve} from 'path';
import {optimize, BannerPlugin} from 'webpack';
import pkg from './package';

const banner = template(readFileSync(resolve(__dirname, 'LICENSE_BANNER'), 'utf8'))({
    pkg,
    date: new Date()
});

const base = {
    output: {
        libraryTarget: 'umd',
        devtoolModuleFilenameTemplate: 'webpack:///sort/[resource-path]'
    },
    module: {
        preLoaders: [{test: /\.js$/, loader: 'source-map-loader'}],
        loaders: [{
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel-loader'
        }]
    },
    devtool: 'source-map'
};

export const build = merge({}, base, {
    entry: './index.js',
Beispiel #21
0
const _template = (tpl) => {
    const compiled = _lodashTemplate(tpl);
    return data => compiled({ ...data, data });
};
Beispiel #22
0
module.exports = function (source) {
  this.cacheable()

  return template(source.toString())(pkg)
}
Beispiel #23
0
 .then((fcontent) => fs.writeFile(
   join(__dirname, '../..', dpath),
   template(fcontent)(locals),
   'utf8'
 ));
Beispiel #24
0
			images = images.map(url => template(url)({ room, user }));
export default function ({ types: t }) {
  return {
    visitor: {
      CallExpression(
        path,
        {
          file: { opts: { filenameRelative } },
          opts: { config: configPath = './webpack.config.js', verbose = true } = {},
        }
      ) {
        // don't process current plugin
        if (typeof getEnhancedResolver === 'undefined') {
          return;
        }

        const { callee: { name: calleeName }, arguments: args } = path.node;

        if (calleeName !== 'require' || !args.length || !t.isStringLiteral(args[0])) {
          return;
        }

        // support env var interpolation into configPath
        const compiledConfigPath = template(configPath)(process.env);
        let config = compiledConfigPath === configPath
           ? localInteropRequire(resolve(process.cwd(), compiledConfigPath))
           : localInteropRequire(resolve(compiledConfigPath));

        if (typeof config === 'function') {
          config = config();
        }

        if (Object.keys(config).length === 0) {
          // it's possible require calls inside webpack config or bad config
          return;
        }

        if (process.env.BABEL_DISABLE_CACHE !== '1') {
          warn(
`babel-plugin-webpack-loader:
To avoid caching errors you need to set BABEL_DISABLE_CACHE=1 environment variable.
More information at issue #36`
          );
        }

        const [{ value: originalFilePath }] = args;

        const parts = originalFilePath.split('!');
        const filePath = parts.pop();
        let loaders = parts.join('!');

        if (loaders) {
          loaders += '!';
        }

        // to support babel builds (babel-node works fine)
        const filenameAbs = resolve(filenameRelative);

        const resolver = getEnhancedResolver(config);

        const fileAbsPath = resolveFilePath(resolver, filenameAbs, filePath);

        if (!fileAbsPath) {
          return;
        }

        // for js and jsx files inside resolve.modules,
        // for absolute folders only i.e. `path.join(__dirname, 'resolveDir')`
        // replace require('xxx') to relative path i.e. `require('../resolveDir/xxx')`
        if (
          isJSFile(fileAbsPath) &&
          !isRelativePath(filePath) &&
          isInAbsResolveModulesPath(config)(fileAbsPath)
        ) {
          const relPath = (
            (p) => (
              isRelativePath(p)
                ? p
                : `./${p}`
            )
          )(relative(dirname(filenameAbs), fileAbsPath));

          // path.replaceWith(t.stringLiteral(relPath));
          path.get('arguments.0').replaceWith(t.stringLiteral(relPath));
          return;
        }

        if (config.module.loaders.some((l) => l.test.test(filePath) || l.test.test(fileAbsPath))) {
          if (isJSFile(fileAbsPath)) {
            // js and jsx files in loaders is unsupported by webpack-loader plugin.
            // all babel settings in loader will be skipped`
            return;
          }

          const webPackResult = runWebPackSync({
            path: loaders + fileAbsPath,
            configPath: compiledConfigPath,
            config,
            verbose,
          });

          const expr = processWebPackResult(webPackResult, config);

          if (expr !== null) {
            if (expr.type === 'FunctionExpression') {
              path.remove();
            } else {
              path.replaceWith(expr);
            }
          } else {
            path.remove();
          }
        }
      },
    },
  };
}
//теперь вынести в темплейт и перенести во вью бекбон
import { View } from 'backbone';
import template from 'lodash/template';
import $ from 'jquery';
window.$ = $;

const PopupView = View.extend({

    template: template(
        $('#view-popup').html()
    ),

    events: {
        'blur .changeEmail': 'editValue',
        'blur .changePass': '******',
        'blur .changeConfPass': '******'
    },

    render: function () {
        this.$el.html(this.template);
        this.$el.find('.modal').modal('show').on('hidden.bs.modal', () => this.remove());
    },

    initialize: function() {
        this.listenTo(this.PopupView, "change", this.render);
        this.render();
    },

    editValue: function (){
        this.PopupView.set({
            email: this.$('.exampleInputEmail1').text(),
"use strict";

var fs = require("fs");
var npath = require("path");
var mkdirp = require("mkdirp");
var randomstring = require("randomstring");
var template = require("lodash/template");

var compiledHtml = template(fs.readFileSync("index.html", "utf8"));

function writeRandom(output, size) {
  while (size > 0) {
    var len = size > 80 ? 80 : size;
    if (len > 3)
      output.push("//" + randomstring.generate({length: len - 3}));
    size -= len;
  }
}

function generateModule(path, size) {
  var output = [];
  var header = "//" + path;
  output.push(header);
  writeRandom(output, size - header.length - 1);
  fs.writeFileSync(path, output.join("\n"), "utf8");
}

function generateHtml(dir, count) {
  var content = compiledHtml({
    moduleCount: count,
    headerElements: function() {
Beispiel #28
0
const remote = (command, host, { excludes }) => {

    const template = require('lodash/template');
    const { Client } = require('ssh2');
    const conn = new Client();

    const sshCommands = {

        /* eslint-disable function-paren-newline */
        backup: template(
            'mkdir -p <%= paths.get("backup") %>;' +
            'filecount=$(ls -t <%= paths.get("backup") %> | grep .tgz | wc -l);' +
            'if [ $filecount -gt 2 ];' +
            'then for file in $(ls -t <%= paths.get("backup") %> | grep .tgz | tail -n $(($filecount-2)));' +
            'do rm <%= paths.get("backup") %>/$file;' +
            'printf "Removing old backup file $file";' +
            'done;' +
            'fi;' +
            'if [ -d <%= paths.get("rsync") %> ]; then ' +
            'printf "Backup folder <%= paths.get("rsync") %> in <%= paths.get("backup") %>/backup-<%= new Date().getTime() %>.tgz";' +
            'tar -cpzf <%= paths.get("backup") %>/backup-<%= new Date().getTime() %>.tgz ' +
            '<%= excludes.map(function (exc) { return " --exclude=\'" + exc + "\'";}).join(" ") %> <%= paths.get("rsync") %>;' +
            'printf "Backup completed";' +
            'fi;'
        )({ paths, excludes }),

        rollback: template(
            'if [ -d <%= paths.get("backup") %> ];then ' +
            'rm -rf <%= paths.get("rsync") %>/;' +
            'for file in $(ls -tr <%= paths.get("backup") %> | tail -n 1);' +
            'do tar -xzpf <%= paths.get("backup") %>/$file;' +
            'done;' +
            'fi;'
        )({ paths })
        /* eslint-enable function-paren-newline */
    };



    if (!command || !sshCommands[command]) {
        throw new Error('SSH command set not specified. Specifiy it via `--command` argument. Allowed commands are: ' + Object.keys(sshCommands).join(', '));
    }

    const { username, password, port = 22 } = host;

    return new Promise((resolve, reject) => {
        conn.on('ready', () => {
            conn.exec(`cd ${host.path};${sshCommands[command]}`, (err, stream) => {
                if (err) {
                    reject(err);
                    return;
                }

                stream.on('close', (code) => {
                    log(`REMOTE: close code: ${code}`);
                    resolve();
                    conn.end();
                }).on('data', (data) => {
                    log('REMOTE: ' + data);
                }).stderr.on('data', (data) => {
                    log(red('REMOTE: ' + data));
                });
            });
        }).connect({
            host: host.host,
            port,
            password,
            username
        });
    });


};
Beispiel #29
0
import pkg from './package';
import isArray from 'lodash/isArray';
import merge from 'lodash/merge';
import template from 'lodash/template';
import {readFileSync} from 'fs';
import {sep} from 'path';
import {optimize, BannerPlugin} from 'webpack';

const banner = template(readFileSync(__dirname + '/LICENSE_BANNER', 'utf8'))({
    pkg: pkg,
    date: new Date()
});

const base = {
    externals: [
        // handle splitting modern lodash paths:
        // import merge from 'lodash/merge'; -> _.merge
        (context, request, callback) => {
            if (/^lodash/.test(request)) {
                let paths = request.split(sep);
                return callback(null, {
                    root: ['_'].concat(paths.length > 1 ? [paths[paths.length - 1]] : []),
                    commonJs: request,
                    commonjs2: request,
                    amd: request,
                    toJSON: () => request // Fixes the source map output (sort of)
                });
            }
            callback();
        }
    ],
Beispiel #30
0
import { View } from 'backbone';
import template from 'lodash/template';
import viewTemplate from './registrationForm.html';
import styles from './registrationForm.css';
import styleHelper from '../../helper/style';
import popupManager from '../../helper/popup';

const RegistrationView = View.extend({
    template  : template(viewTemplate),

    initialize: function () {
        this.promise = new Promise((resolve, reject) => {
            this.resolveF = resolve;
            this.rejectF = reject;
        });
    },

    events: {
        'click #submit_registration': 'validationF',
        'focus #registration_modal input': 'removeErrorValidation'
    },

    removeErrorValidation: function () {
        event.target.classList.remove(styles['validation-error']);
    },

    validationF: function (e) {

        function checkValidate(e) {
            e.preventDefault();
            const emailField = document.querySelector('#email');