Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting an error thrown from a $ in the template #11

Open
chrisnicola opened this issue Nov 19, 2015 · 2 comments
Open

Getting an error thrown from a $ in the template #11

chrisnicola opened this issue Nov 19, 2015 · 2 comments

Comments

@chrisnicola
Copy link
Contributor

I'm trying to parse some of what were originally SLIM templates using webpack. I've created a pretty basic loader (code below) and it works for the most part but I'm getting some unusual errors being thrown. I'm also not getting line numbers from the errors, nor does the error look like something from the SLM library.

The Loader:

'use strict';

var loaderUtils = require("loader-utils");
var slm = require("slm");
var markdown = require("slm-markdown")
markdown.register(slm.template)

module.exports = function(source) {
  this.cacheable && this.cacheable(true);
  var query = loaderUtils.parseQuery(this.query);
  var req = loaderUtils.getRemainingRequest(this).replace(/^!/, "");
  slm.compile(source)()
}

The error

15:05:29 webpack.1 | Module build failed: SyntaxError: Unexpected token :
15:05:29 webpack.1 |   at VM.exports.runInThisContext [as runInContext] (vm.js:53:16)
15:05:29 webpack.1 |   at Template.p.exec (/Users/chrisnicola/src/wealthbar/node_modules/slm/lib/template.js:100:13)
15:05:29 webpack.1 |   at Template.p.compile (/Users/chrisnicola/src/wealthbar/node_modules/slm/lib/template.js:77:17)
15:05:29 webpack.1 |   at Object.module.exports (/Users/chrisnicola/src/wealthbar/webpack/loaders/slm.js:12:22)
15:05:29 webpack.1 |  @ ./webpack/wealthbar/views/index.coffee 43:23-63

The line that is causing it:

          p()
            | Net income ${{options.income - results.totalTax | number:2}}

If I remove the $ it works. This is an angular template so it is meant to return a currency value, hence the dollar sign.

@chrisnicola
Copy link
Contributor Author

I'm guessing that it is interpreting this as a ES6 template string, so I will have to escape the $ as \$. This is probably not be a bug.

@chrisnicola
Copy link
Contributor Author

Actually I would suggest this is a bug in that there is no line number reported. So the error is pretty confusing from that standpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant