Skip to content

add a regex replacement interface #91

@kylemac

Description

@kylemac

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions