Editing Twig templates in CKeditor

One possible workaround for me, was to add the Twig blocks to config.protectedSource:

CKEDITOR.config.protectedSource.push(/\{%\s.+\s%\}/g);

They will be ignored in the WYSIWYG editor, but will still be visible in the source code view.

Additionally you can install the plugin Show protected and there's still a visible hint.


working code is :

CKEDITOR.config.protectedSource.push(/{{[\s\S]?}}/g); CKEDITOR.config.protectedSource.push(/{\%[\s\S]?%}/g); CKEDITOR.config.protectedSource.push(/{#[\s\S]*?#}/g);

because we need allow {{ and {% tags for twig