carrot / sprout

:seedling: simple project templating & skeletons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add a regex replacement interface

kylemac opened this issue · comments

so, in building out a sprout template that compiled an Android project we came across a use-case where we didn't want to write our EJS directly in the source code. Instead we created an interface for comments (we never ended up doing this) that included the EJS so we could compile our /root directory as a normal project (aka not breaking because it was filled with EJS).

so i'm thinking we build this into sprout itself (partially because there's not many other features I can think of). here's a sketch of the interface

# init.coffee
exports.replace = [
  {
    regex: '<h1>name</h1>'
    replacement: '<h1><%= name %></h1>'
    paths: '**.coffee'
    recursive: true
  }
]

we could basically proxy to this: https://github.com/harthur/replace (as we did in the android project).

also, the more I think of this - i can already imagine improvements. while i think a bit more critically of those, I'll share this sketch.

would love your input @nporteschaikin

nudge @nporteschaikin. we're going to take a swipe at this soon, but would like your input first

@kylemac: Is this just a find/replace function? I'm 👍 on this; I can even take a swipe at it if you want.

yup yup - just a find and replace. if you've got some time, it'd be great to have you take the first swipe

@kylemac Will take a swipe at this before EOW.

@kylemac Obviously late af on this. Will take a look again this week.

👌 hope all else is groovy