Search code examples
yii2twigsmarty

How save smarty template into db and then render that from controller in yii2?


Im trying to develop a website with some users who can write blogs. In this site users need to be able to save their template created by smarty or twig to db and then i will render that from db.

Any one have any idea about how i render templates from database?


Solution

  • http://www.smarty.net/docs/en/resources.string.tpl

    load template from database ->into string -> render.

    don't forget about caching and security though

    it's harder to do with a twig (because of twig's inheritance), but - in a limited way - possible .