simon-dt / gulp-twig

Twig plugin for gulp.js, The streaming build system. Looking for maintainer or collaborators. See wiki
https://github.com/zimmen/gulp-twig/wiki/Looking-for-maintainer-or-collaborator(s)
MIT License
62 stars 33 forks source link

How to use function "source"? #59

Open crazydeath137 opened 5 years ago

crazydeath137 commented 5 years ago

as I see, Twig has a good function named "source" : https://twig.symfony.com/doc/1.x/functions/source.html But I can't use it in gulp-twig. {{ source(file_path) }} --> all I see is a message like this "Template "file_path" is not defined."

this function is very usefull to me, Tks for ur reading.

crazydeath137 commented 5 years ago

my solution to include raw file is create a new function.

`

functions:[ { name: "include_raw", func: function (path) { var content = 'content'; content = fs.readFileSync('app/'+path).toString(); return content; } } ]

`

and use it `

{{ include_raw('haha.html') }}

`