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

feat(custom): custom render prismic type #7

Merged
merged 1 commit into from
Feb 10, 2021
Merged

feat(custom): custom render prismic type #7

merged 1 commit into from
Feb 10, 2021

Conversation

mrloop
Copy link
Member

@mrloop mrloop commented Feb 1, 2021

See updated README and tests for examples.

Custom rendering of prismic type using custom component for prisimc type.

Pass a custom component name to be used to render a prismic type. For example to custom render the 'group-list-item' and 'hyperlink' types

<Prismic::Dom                                                                             
  @group-list-item='my-list'                                                              
  @hyperlink='my-hyperlink'                                                               
  @nodes={{@myPrismicDoc.data.myRichText}}                                                
/>                                                                                        

my-list.hbs

<h1>My List</h2>                                                                          
<ul>{{yield}}<ul>                                                                         

my-hyperlink.hbs

<a href={{@node.element.data.url}}>{{yield}}</a>                                          

Useful Links

Alternatives

Explored using named blocks https://github.com/qonto/ember-prismic-dom/compare/em-custom, it would give a nicer interface, allowing you to declare custom type rendering in the same template as Prismic::Dom is used. However the implementation was going to be very verbose and broken. https://github.com/qonto/ember-prismic-dom/compare/em-custom#diff-0b7a759bb6f26f39ae19fb331cc235b7c6588d834f0204c37e2f350306fa6d33R2 errors Syntax Error: {{yield}} can only accept a string literal for the to argument (at ember-prismic-dom/components/prismic/children.hbs on line 2 column 20)

Closes #3

@mrloop mrloop added the enhancement New feature or request label Feb 1, 2021
@mrloop mrloop self-assigned this Feb 3, 2021
@mrloop mrloop merged commit c839e62 into main Feb 10, 2021
@dbendaou dbendaou deleted the em-custom-comp branch May 19, 2021 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a mechanism for custom tag rendering
2 participants