cferdinandi / reef

A lightweight library for creating reactive, state-based components and UI.
https://reefjs.com
MIT License
1.16k stars 77 forks source link

Loading template from a file #133

Closed mouse0270 closed 2 years ago

mouse0270 commented 3 years ago

Hello, I actually switched from using handlebars to reef because I found reef to be more what I was looking for, since handlebars required me to basically redraw everything. The one thing I miss / don't know how to due. Is there a way to store the template as a file and use something like fetch

Right now I basically created a giant class that stores all of my templates, but I think it would be much nicer to store the template in a file called something like input.reef which has the following code

<div class="form-group">
    <label for="${props.id}">${props.label}</label >
    <input type="${props.type}" name="${prop.id}" value="${props.value}" />
</div>

then fetch it in some way that wont break the ${props...} method?

Edit if this is out of the scope of this project or not possible, that is fine, I just wanted to check before I assumed that.

cferdinandi commented 2 years ago

Kind of, sort of a duplicate of this: https://github.com/cferdinandi/reef/issues/121

The Reef API has changed since then, but the basic approach should be the same. Let me know if you can't figure it out, though, and I'll try to put something together.