function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajalakshmi SubramaniamRajalakshmi Subramaniam 

Render HTML (stored in field) dynamically in LWC

Hello all,

Is it possible to render HTML template dynamically in lightning web component. For example:
HTML template has been stored in a field called HTML__c. i need to read the field and render the same in UI.
I am not sure this is possible.
Anyone know if i can do this?? 
Appreciate your help!
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Rajalakshmi,

I see that you are trying to dynamically render elements in lwc so I was able to find the below implementations that you can try checking and modify as per your need.

>> http://www.0to1code.com/using-if-and-else-lightning-web-components-with-tom-jerry/

>> https://sfdcbrewery.github.io/DynamicRenderingInLWC/#:~:text=5x%20Dreamforce%20speaker-,Dynamic%20HTML%20and%20CSS%20rendering%20in%20Lightning%20Web%20Components%20(LWC,to%20update%20the%20UI%20conditionally.

>> https://salesforce.stackexchange.com/questions/243876/dynamic-component-creation-in-lightning-web-components

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Rajalakshmi SubramaniamRajalakshmi Subramaniam
Hi ANUTEJ,

Thank you the the prompt Response! 

I have gone throught the links. Actually i need to render the HTML dynamically not conditionally.. 
Whole HTML part has been stored in a field and i need to render the same in lwc.
Please let me know if i could acheive this.
Thank you!