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

Type safe templating (with mustache) #128

Open
wants to merge 8 commits into
base: master
from
Open

Type safe templating (with mustache) #128

wants to merge 8 commits into from

Conversation

@Drup
Copy link
Member

Drup commented Apr 18, 2016

This is WIP.

open Tyxml

let%template f ={|
Hello {{name}}, You are {{{desc}}}
{{#list}}
  <b>{{foo}}</b> {{name}}
{{/list}}
{{^list}}
  No foos :(
{{/list}}
|}

val f :
  name:bytes ->
  list:< foo : bytes; .. > list ->
  desc:([> `B | `PCDATA ] as 'a) Tyxml_html.elt list ->
  'a Tyxml_html.elt list

Current issues:

  • Locations are completely lost (because of the mustache implementation)
  • Nesting is untested
  • Can't specify a name relative to the current context. Names are always resolved from the top context.
@Drup Drup force-pushed the template branch from fe5c58a to cfd4908 Apr 19, 2016
@aantron
Copy link
Contributor

aantron commented Apr 19, 2016

I think this is (potentially) a great idea, but I don't think TyXML should offer two PPXs as in the attached commits. Ideally, there would be "one great TyXML PPX" that offers this and whatever other features. Otherwise, we are likely to confuse new users and make them anxious about going down the wrong path with their code.

@Drup Drup force-pushed the template branch 2 times, most recently from 520524d to e6b7ca0 May 7, 2016
@Drup Drup force-pushed the template branch from e6b7ca0 to 7f83de0 May 7, 2016
@Drup Drup force-pushed the template branch from 7f83de0 to 1e2714f Feb 25, 2017
@Drup Drup force-pushed the template branch from 75ca75b to f0dc427 Apr 13, 2018
@Drup
Copy link
Member Author

Drup commented Apr 16, 2018

If people want this to happen, please voice your opinion on the choice of the templating language in https://discuss.ocaml.org/t/choice-of-template-language-for-tyxml/1863 .

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.