3 ms·
Ah, so close. I really just want something like Handlebars, with a generic adapter for any language for compilation. Then you can load with javascript a clien
by tabeth 10y ago
Ah, so close.
I really just want something like Handlebars, with a generic adapter for any language for compilation.
Then you can load with javascript a client-side controller if you want to add in interactivity.
---
To expand, I think the idea solution would be the following:
1. Server side view, let's call it "Bars"
2. Bars can be written on the front-end or back-end, does't matter. It'll compile to BarsHTML.
3. If you write Bars on the back-end, then when you serve your page it'll compile Bars into BarsHTML.
3a. If you want to sprinkle JS onto Bars, you'll use BarsControllerJS, an adapter to whatever framework of your choice, to manipulate it. The main difference between this and manipulating the DOM is that the interface to do this is not DOM centric.
4. If you write Bars on the front-end, it's the same as (3), but you get (3a). If you decide you'd rather do server side rendering, you literally just move your views to the server. The controller is already abstracted, so you wouldn't need to do anything else.
- bhurlow 10y agoYou can use Next.js to do server-side only rendering. It uses React idioms for rendering in favor of vanilla templating
- laktek 10y agoNot exactly the same, but what you describe is similar to the concept of components in Pragma (a project I'm working on). I will write a more detailed post when it's ready for release. Meanwhile you can check the "How Pragma works" in the intro blog post http://www.laktek.com/2016/11/29/introducing-pragma/ http://www.laktek.com/2016/11/29/introducing-pragma/
- gniquil 10y agoI think you miss the point of having Next.js being based on React. Although I think handlebars/htmlbars are great (I'm a big ember user), the cool thing about React is it's component based. So pretty much everything you mentioned above, replace BarsHtml to react components, you have Next. However, the react components though in my opinion is much better than handlebars. It is more powerful, more flexible and at the same time more disciplined.
- ramses0 10y agoTake a look at http://markojs.com/ http://markojs.com/ and http://markojs.com/docs/installing/ http://markojs.com/docs/installing/ test.marko: `<h1 on-click('callMyFunc')>${ input.hello }</h1>` component.js: `class { callMyFunc(e) { console.log(e); } }` ...gets compiled to test.marko.js which can then be require'd or using a special runtime loader or transformer. It hits a nice sweet spot for me, and is worth checking out.