Open KatieMFritz opened 7 years ago
Do you have any empty files? Might be Buffer.from
here that throws because of an empty string.
@kevva Thanks for responding! I don't have any empty files in source.templates
. Here's my folder structure:
Hi,
same problem here. It throws: First argument must be a string, Buffer... if i use something wrong as a macro-parameter for example. Its ok to show an error-message here but if it throws the gulp-process with all watchers gets canceled so users have to manually restart it. I use plumber for catching those plugins but here it does not work :/ Is it possible to just not throw the errors?
My code...
.pipe(gulpNunjucks.compile({}, {
env: nunjucksEnv
}))
.pipe(plumber({ handleError: handleError }))
Thank you.
I'm getting this error when I try to use macros that are defined in a file that's included. As soon as I remove the macros, the error goes away.
[00:14:11] Starting 'compHTML'...
[00:14:11] 'compHTML' errored after 152 ms
[00:14:11] TypeError in plugin "gulp-nunjucks"
Message:
First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
Details:
fileName: /Users/nick/Development/**/cause.njk
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false
/**
* COMP_HTML
*
* Compile nunjucks into html
*/
const compHTML = () => {
htmlComped = true
return gulp
.src('src/**/*.njk')
.pipe($.data(config))
.pipe($.nunjucks.compile())
.pipe($.filter(['**', '!_*'])) // Remove files we don't want exported
.pipe(
$.rename(function (path) {
path.extname = '.html'
})
)
.pipe(gulp.dest('public'))
}
{% extends "./templates/_base.njk" %}
{% import "includes/mixins.njk" as mixins with context %}
{% import "includes/mxCause.njk" as mxCause with context %}
{% block main %}
{{ mxCause.circleStat('Education-circle-2', '5,390hrs', 'Volunteered') }}
{% endblock %}
{% macro circleStat(imgName, number, stat) %}
<div>
<img class="width-6 height-6" src="/assets/img/circles/{{imgName}}.svg"/>
<h1 class="type-h mb-0 pb-0">{{number}}</h1>
<spam class="type-d">{{stat}}</span>
</div>
{% endmacro %}
Let me know if there's any additional information I can provide, or some type of debug mode I can enable on the plugin.
Hello! I'm trying to use
gulp-nunjucks
to compile Twig syntax in PatternLab Node Gulp edition.I keep getting the following error, and I'm not sure how to resolve it:
Here's the relevant part of my
gulpfile.js
:I understand that
compile
takes two arguments,data
andoptions
. It seems like I have two arguments there,{}
and myenv
option.My end goal is to get html files in my
public.templates
directory, so maybe there is a function I could use besidescompile
? I'm open. If I replacecompile
withprecompile
and remove the first argument,gulp nunjucks
completes with no errors, but it doesn't seem like it actually does anything.Please help me figure out what I'm missing! Thank you in advance. 🙇♀️