UNPKG

@titanium/turbo

Version:

<p align="center"> <img src="https://cdn.secure-api.org/images/turbo-title_400.png" /><br> <a href="https://www.npmjs.com/package/@titanium/turbo"> <img src="https://img.shields.io/npm/v/@titanium/turbo.png" /> </a> </p>

25 lines (22 loc) 841 B
// Walk tree transformer changing "`......`" to `......` and "~......~" to ...... // This will allow you to use controller args in contained views/controllers module.exports = function (_ref) { var types = _ref.types; return { pre: function (state) { }, visitor: { Property: function (path, state) { if (types.isStringLiteral(path.node.value)) { const regex1 = /^`([^`]+)`$/; const regex2 = /^~([^`]+)~$/; if ( regex1.test(path.node.value.value) ) { path.replaceWith(types.ObjectProperty(types.identifier(path.node.key.name), types.Identifier(path.node.value.value))); } else if ( regex2.test(path.node.value.value) ) { path.replaceWith(types.ObjectProperty(types.identifier(path.node.key.name), types.Identifier(path.node.value.value.replace(regex2, '$1')))); } } }, } }; };