lazd / DOMly

The fast template system that creates and clones DOM nodes
MIT License
53 stars 9 forks source link

Expose Compiler to extend features #18

Closed terinjokes closed 9 years ago

lazd commented 9 years ago

@terinjokes, it's easy to expose the Compiler constructor, but there are a number of utility methods that aren't on Compiler's prototype:

I'll move those to the prototype, then export Compiler so it's available. Would that give you what you need?

terinjokes commented 9 years ago

@lazd I honestly just needed to override setTextContent to use a utility library, since el.textContent isn't cross-browser enough for my needs.

(That said, all the usages of setTextContent went away when I fixed the stripWhitespace bug I'm clean up to PR to you…)

lazd commented 9 years ago

@terinjokes, I went ahead and simply exposed the Compiler constructor in the exported module. You can now extend it and override setTextContent or simply monkey-patch the prototype.

That should handle your use case. If the other functions I mentioned become required, we can just throw them on Compiler's prototype.

This issue opened my eyes to the fact that people are definitely going to want to change DOMly's output in various ways, so the compiler should facilitate that. I'll be thinking about that in general, let me know if you have thoughts on how to expose that kind of flexibility in a simpler way.

terinjokes commented 9 years ago

@lazd how often do you do releases?

lazd commented 9 years ago

I haven't released yet as I was trying to get a solid test on another issue I closed with @cif. I'll release tomorrow.

lazd commented 9 years ago

@terinjokes, a bit late, but I've released DOMly@0.0.7 that includes the fix for this issue.