Sha256: 49a027bc8785d92397987ef6104db8095c0fd456c77d75582a774bac5aa831b4

Contents?: true

Size: 948 Bytes

Versions: 24

Compression:

Stored size: 948 Bytes

Contents

"use strict";
const tokenize = require("postcss/lib/tokenize");

function templateTokenize () {
	const tokenizer = tokenize.apply(this, arguments);

	function nextToken () {
		const args = arguments;
		const returned = [];
		let token;
		let depth = 0;
		let line;
		let column;

		while ((token = tokenizer.nextToken.apply(tokenizer, args))) {
			if (token[0] !== "word") {
				if (token[0] === "{") {
					++depth;
				} else if (token[0] === "}") {
					--depth;
				}
			}
			if (depth || returned.length) {
				line = token[4] || token[2] || line;
				column = token[5] || token[3] || column;
				returned.push(token);
			}
			if (!depth) {
				break;
			}
		}
		if (returned.length) {
			token = [
				"word",
				returned.map(token => token[1]).join(""),
				returned[0][2],
				returned[0][3],
				line,
				column,
			];
		}
		return token;
	}
	return Object.assign({}, tokenizer, {
		nextToken,
	});
}

module.exports = templateTokenize;

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.7 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.6 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.5 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.4 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.3 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.2 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.1 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3.5 node_modules/postcss-html/template-tokenize.js
trusty-cms-5.0.0 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3.4 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3.3 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3.2 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3.1 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.3 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.2.3 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.2.2 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.2.1 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.2 node_modules/postcss-html/template-tokenize.js
trusty-cms-4.1.9 node_modules/postcss-html/template-tokenize.js