hygen icon indicating copy to clipboard operation
hygen copied to clipboard

skip_if needs to support variable

Open u007 opened this issue 1 year ago • 3 comments

i wish this could work:

---
skip_if: "<%=pluralName %>: "
---

ive my work around, but would love to see this instead

u007 avatar Jan 03 '24 16:01 u007

what's your workaround?

Maker-Mark avatar Mar 27 '24 20:03 Maker-Mark

i return a boolean variable in prompt, and do a ternary on template like this. instead of writing to the actual file, i wrote it to the .tmp directory to avoid replacing the file

---
to: "<%= generateList ? 'pages/cp1/' : '.tmp/void/' %><%=pluralName%>/[<%=name%>Id]/index.vue"
---

u007 avatar Mar 28 '24 01:03 u007

@u007 You can just return null and it wont generate. That's a lot better than putting files into .tmp. https://www.hygen.io/docs/templates/#conditional-rendering

Maker-Mark avatar Apr 01 '24 18:04 Maker-Mark