-
Notifications
You must be signed in to change notification settings - Fork 29
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
[TypeError: cleanSource(...).replace is not a function] #77
Comments
@philmaker1 , please give us more details, mainly the tag that is generating the error. |
@philmaker1 with no infos we can help you on this issue. I will be glad to reopen it whenever you will find a bit of time for us |
@philmaker1 Were you reading the file with the 'fs' module? You may have inadvertently been passing a Buffer into riot.compile(). If you read the documentation for the fs.readFile callback, you'll see how the type of the second parameter changes depending on how readFile() is called. test.tag: <test>
<h2>Hello, World!</h2>
<script>
this.f = function() {
};
this.v = opts.value;
</script>
</test> riot.js: var riot = require('riot');
var fs = require('fs');
fs.readFile('test.tag', function(err, tag) {
if (err) {
console.error(err);
} else {
console.log(riot.compile(tag));
}
}); Error
Solution 1: // Specify the encoding and tag will be a string
fs.readFile('test.tag', 'utf8', function(err, tag) { Solution 2: // Call toString() on the buffer
console.log(riot.compile(tag.toString())); Either way, no more error
|
When I call compiler.compile within node, the compile fails.
[TypeError: cleanSource(...).replace is not a function]
The same tag compiles fine in the browser.
node v4.4.7
riot-compiler: v2.5.2
The text was updated successfully, but these errors were encountered: