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

Change output extension #19

Closed tremby closed 7 years ago

tremby commented 8 years ago

I'm looking for an option to change the extension to some arbitrary string. I saw that there is a proposed option to leave the extension as it is on input over in #14, but this wouldn't do the trick for me.

Any chance of adding this?

tremby commented 8 years ago

Working around it using gulp-rename for now.

simon-dt commented 8 years ago

Yeah, it would be possible to create an option that defaults to '.html' and can be overwritten. I'm cusrious what the usecase would be!

tremby commented 8 years ago

My use case was using twig to produce a file which was not HTML. Twig documentation itself says it's good to output any text-based language: http://twig.sensiolabs.org/doc/templates.html#synopsis

In this case I am using twig for HTML templates, but also needed a template for an icon font stylesheet, outputting stylus source code. It didn't make sense to add a dependency for another templating language just for this one part of the build process, so I chose to write the template in twig. But gulp-twig insisted on saving the output as .html.

DavidBadura commented 7 years ago

:+1: can i help? would it be accepted if i create a PR?

olets commented 7 years ago

I think gulp-rename is the correct solution. Gulp plugins are meant to be modular, and gulp-twig is meant to be a wrapper for twig compilation. Duplicating gulp-rename's functionality seems outside the scope of gulp-twig, even if it does look similar to the renaming it's already doing (the current renaming is fundamental to the twig -> html compilation)

tremby commented 7 years ago

I disagree. A tool which renders Twig should not assume HTML is being written. As I pointed out before, the Twig documentation itself says the following:

A template is simply a text file. It can generate any text-based format (HTML, XML, CSV, LaTeX, etc.).

Allowing the user to specify the output filename would not be duplicating gulp-rename's functionality -- gulp-rename does a whole lot more.

olets commented 7 years ago

Yes my comment was poorly worded in a couple ways. I'm wondering why not use gulp-rename?

tremby commented 7 years ago

I do, as mentioned in a previous comment. But I see it as a workaround which should not be necessary. gulp-twig should not be assuming I'm writing HTML.

bezoerb commented 7 years ago

Also disagree here. We're also got some undocumented option changeExt to prevent the renaming. So why not just allow passing a value for extname which defauts to '.html'. Prepared a PR: https://github.com/zimmen/gulp-twig/pull/38

ghost commented 7 years ago

38 is now merged

olets commented 4 years ago

Ftr @tremby though I went dark in this thread you completely changed my mind. Now whenever it comes up I advocate for not assuming twig is being used for html. Glad you stood strong