Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a more robust library for view rendering #127

Open
joefitter opened this issue Jun 21, 2016 · 2 comments
Open

Use a more robust library for view rendering #127

joefitter opened this issue Jun 21, 2016 · 2 comments

Comments

@joefitter
Copy link
Contributor

Currently we use Hogan and Mustache to render views on the server before passing to the client. I believe this could be better achieved by using a dedicated view library such as React or Vue.js (with JSDOM).

Template mixins could be replaced a set of React components which contain all rendering logic and required into templates that need them:

import { Form, RadioGroup, Submit } from 'hof-components'

export default ({
  step
}) => (
  <Form step={step}>
    <RadioGroup ref='some-ref' />
    <Submit />
  </Form>
)

As React uses virtual DOM we would be able to benefit from universal rendering - send the rendered HTML to the client, but also benefit from client side JS without having to include onDomReady JS such as progressive reveal. This could actually be achieved with most front end view libraries by using JSDOM to render to HTML before sending to the client.

I see this way as more maintainable than having res.locals with a bunch of potentially conflicting mustache mixins in the same namespace.

Thoughts @JoeChapman @easternbloc @daniel-ac-martin ?

@joefitter
Copy link
Contributor Author

Also as a note to add - with the above example I would still like to hide the rendering logic from the end user, they would only be concerned with a config file which would loop over steps and fields to render the forms programmatically. Overrides and custom HTML if really needed would be achieved in a similar way to how they are currently

@gavboulton
Copy link

I like the idea of this. It's definitely worth spiking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants