loreanvictor / tmplr

Automate Code Scaffolding
MIT License
26 stars 0 forks source link

Enable pipes to be applied to things like `filesystem.rootdir` #31

Closed fwextensions closed 9 months ago

fwextensions commented 9 months ago

It would be nice to be able to use a transformed version of the current directory name, something like this:

  - read: pluginName
    prompt: What is the name of your plugin?
    default:
      from: {{ filesystem.rootdir | Capital Case }}

Tried doing something similar with an eval string, but it didn't work.

loreanvictor commented 9 months ago

You already can:

steps:
  - read: pluginName
    prompt: What is the name of your plugin?
    default:
      eval: '{{ filesystem.rootdir | Capital Case }}'

P.S. its strange, I thought I already commented on this 😅

fwextensions commented 9 months ago

This stemmed from my fuzziness on string handling in yaml, which I've used it a lot, but there are still edge cases that can trip you up. I assumed that {{ someToken }} could be written anywhere without quotes, but I guess it could be confused with an object literal. I think because you (obviously) don't need quotes around a token inside a file that's read in that you also wouldn't need them in the recipe itself.

Anyway, this works fine with quotes.

loreanvictor commented 9 months ago

yeah routinely trips me too, but I kind of understand why the yaml syntax could not support this.