Open anithri opened 7 years ago
It would be nice if we could also find a way to collect various import statements and emit them to the top of the file as part of the final write.
This allows partials to cleanly inject additional statements, and they all end up grouped at the top of the file
Lets add a partials
directory at the top level of blueprints.
Under that will be ejs files named for the specific partial it is.
/smart
/files
__root__
...
/partials
/propTypes,js
/styles.css
Add two predicates to the blueprint obj. hasPartials
and hasFiles
. that are false if the respective directories are missing or empty.
partials names can optionally include the name of the blueprint from which you want to take it like smart.proptypes || proptypes@smart || smart/propTypes
with the idea being if the blueprint name is missing it looks for the first partial that matches the name regardless of which blueprint it comes from.
Add a ejs helper to simplify including a partial that checks to see if it is supposed to render it and which file to render.
Add partial lookup that does a blueprint lookup and additional checks for the partial file. These can be cached during the intial blueprint lookup.
ejs doesn't seem to have the equivalent of ruby's content_for
. Which makes inserting into blocks more problematic.
# auto-generated do not edit
or # End of Imports
or # all imports above here
Imagine 3 standard concerns.
And being able to include a partial for that concern in a blueprint as simply as
<%= propTypePartial %>
This would ensure consistency of these across multiple blueprints. And enable concerns to be customized (think styled components vs imported css or an empty partial for the propTypes.
I don't have any solid ideas on how to pull it off. Any ideas about the standards of naming, discovery, how it's called from an ejs file, concerns for looping through an object or array...