Describe the feature you'd like to request
You can use mustache templating in @display, @field.relation, @list.template, @view.template to describe rows in form fields, search columns and bread crumbs.
model ArticleComment
@display("{{comment.profile.name}} {{comment.profile.email}} - {{comment.message}}")
@query("*" "article.*" "comment.*" "comment.profile.*")
{
articleId String @id
commentId String
@label("Note") @id
@field.relation({
id "id"
search "/admin/comment/search?json"
template "{{message}}"
})
@filter.relation({
id "id"
search "/admin/comment/search?json"
template "{{message}}"
})
@list.template({ template "{{comment.message}}" })
@view.template({ template "{{comment.message}}" })
article Article @relation({ local "articleId" foreign "id" })
comment Comment @relation({ local "commentId" foreign "id" })
}
Consider a comment model where there is no column to easily label a comment. In the generated components for comments using the entire message to represent a row will break the intended layout interface.
Describe the solution you'd like
I would like to switch out mustache to handlebars in the generators and add the following handlebar helpers to start.
- clip -
{{clip comment 25}}...
- either -
{{either name email}}
- formula -
{{#formula}} {{order.subtotal}} + {{order.shipping}} {{/formula}}
- uppercase -
{{uppercase country}}
- lowercase -
{{lowercase status}}
This way, we can change the templates to look like the following (and will generate more pleasing results).
model ArticleComment
@display("{{either comment.profile.name comment.profile.email}} - {{clip comment.message 25}}...")
@query("*" "article.*" "comment.*" "comment.profile.*")
{
articleId String @id
commentId String
@label("Note") @id
@field.relation({
id "id"
search "/admin/comment/search?json"
template "{{clip message 25}}..."
})
@filter.relation({
id "id"
search "/admin/comment/search?json"
template "{{clip message 25}}..."
})
@list.template({ template "{{clip comment.message 25}}..." })
@view.template({ template "{{clip comment.message 25}}..." })
article Article @relation({ local "articleId" foreign "id" })
comment Comment @relation({ local "commentId" foreign "id" })
}
Describe alternatives you've considered
Generators also use mustache to some extent to generate code. But it should be okay to swap this out because handlebars markets that it is built on top of mustache and is backwards compatible with mustache templates. We just need to double check the generated code for type errors.
Describe the feature you'd like to request
You can use mustache templating in
@display,@field.relation,@list.template,@view.templateto describe rows in form fields, search columns and bread crumbs.Consider a comment model where there is no column to easily label a comment. In the generated components for comments using the entire message to represent a row will break the intended layout interface.
Describe the solution you'd like
I would like to switch out mustache to handlebars in the generators and add the following handlebar helpers to start.
{{clip comment 25}}...{{either name email}}{{#formula}} {{order.subtotal}} + {{order.shipping}} {{/formula}}{{uppercase country}}{{lowercase status}}This way, we can change the templates to look like the following (and will generate more pleasing results).
Describe alternatives you've considered
Generators also use mustache to some extent to generate code. But it should be okay to swap this out because handlebars markets that it is built on top of mustache and is backwards compatible with mustache templates. We just need to double check the generated code for type errors.