@zackad/prettier-plugin-twig 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -14,7 +14,22 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import * as t from "@babel/types";
|
|
17
|
-
import
|
|
17
|
+
import isFunction from "lodash/isFunction.js";
|
|
18
|
+
import _template from "@babel/template";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* For some reason there's inconsistency when importing "@babel/template" on
|
|
22
|
+
* vitest environment and loading this plugin directly on cli. I have no idea why
|
|
23
|
+
* this happens but this workaround seems to be fixed it.
|
|
24
|
+
*
|
|
25
|
+
* Without this workaround, an error will occur either on test or when loading
|
|
26
|
+
* plugin on cli. This error doesn't happen on `src/melody/melody-extension-core/visitors/for.js`.
|
|
27
|
+
* ```
|
|
28
|
+
* [error] template is not a function
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const template = isFunction(_template) ? _template : _template.default;
|
|
32
|
+
|
|
18
33
|
// use default value if var is null, undefined or an empty string
|
|
19
34
|
// but use var if value is 0, false, an empty array or an empty object
|
|
20
35
|
const defaultFilter = template("VAR != null && VAR !== '' ? VAR : DEFAULT");
|