Skip to content

Instantly share code, notes, and snippets.

@sylvaincombes
Last active March 30, 2018 08:51
Show Gist options
  • Save sylvaincombes/19b756f17a7254cd682238ac7897a03c to your computer and use it in GitHub Desktop.
Save sylvaincombes/19b756f17a7254cd682238ac7897a03c to your computer and use it in GitHub Desktop.
Symfony Ivory CkEditor protect twig syntax protectedSource
ivory_ck_editor:
configs:
default:
# ...
# protect twig syntax
entities: false
protectedSource: ["/\{\{[\s\S]*?\}\}/g", "/\{\%%[\s\S]*?\%%\}/g", "/\{\#[\s\S]*?\#\}/g"]
# @see http://ckeditor.com/addon/showprotected for a plugin with a visual indicator / editor of protected source if needed
@bastos71
Copy link

Thanks for the tip !

Just one thing : each protected source marker should be wrapped with simple quotes, at least with symfony 3.4.6 :)
And I personnaly removed the {{ }} tags from the protectedSource config to let those parameters in the content area for end users

ivory_ck_editor:
 configs:
   default:
     # ...
     # protect twig syntax
     protectedSource: ['/\{\%%[\s\S]*?\%%\}/g', '/\{\#[\s\S]*?\#\}/g']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment