Skip to content

[Question] Is it possible to use if condition based on the current build file extension? #456

Answered by cossssmin
seyfer asked this question in Q&A
Discussion options

You must be logged in to vote

You could use the (currently undocumented) page.build.currentTemplates object, which contains your page.build.templates[x] object for every iteration, when multiple templates sources are used.

With that you should be able to access the currently-being-built templates' extension through:

{{ page.build.currentTemplates.destination.extension }}

Note that page.build.currentTemplates is only available to you inside a template, not in a config file.

However that might get tedious to write all the time, so I'd recommend using environment configs, as you suggested with config.laravel.js. You'd then write your HTML like this:

<img src="{{ page.env === 'laravel' ? 'asset(images/logo.png)' : 'image…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@seyfer
Comment options

@seyfer
Comment options

@cossssmin
Comment options

Answer selected by seyfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #454 on May 06, 2021 10:24.