Closed jowan closed 3 years ago
Actually, the pattern_preview() function in TwingRenderer.js does seem to do the trick, so I just cloned that and replaced the pattern function. From:
this.environment.addFunction(new TwingFunction('pattern', _twigRenderEngine.renderPattern));
/**
* Naughty hack, just cloning pattern preview here, as pattern() not working as expected.
*/
this.environment.addFunction(new TwingFunction('pattern', function (patternId) {
var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var variantId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _Pattern["default"].DEFAULT_VARIANT_NAME;
return new Promise(function (resolve) {
(0, _twigRenderEngine.renderPatternPreview)(patternId, variables, variantId).then(function (output) {
resolve(output);
});
});
}));
Now I can correctly use {{ pattern('bs-accordion-item', vars, variant) }}
and export to Drupal, and all is good.
Hi it is fixed in 1.1.0-alpha.1. Thanks for reporting.
Great!
Confirmed working in 1.1.0-alpha.1 - thanks for the fix
Describe the bug
When I pass a variant to the pattern twig function it is ignored. It does work with pattern_preview though.
To Reproduce
Use both pattern and pattern_preview in a template with a variant and compare results.
Expected behavior
pattern twig function should respect variant and load what ever settings are bundled in that variant.
Screenshots
Screen shot of rendered template:
Additional context
Here is my template, calling both pattern and pattern preview:
And here is my sub template's (the one being called above) wingsuit.yml:
I think that pattern(patternID, vars, variantID) should apply my variant here, which just contains some classes.
Thanks for your help :)