Twig Tricks and HTML Escaping

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:05
    with Leanna Pelham
  • 0:08
    You're a pro now, so let's have a little fun
  • 0:10
    and see some sweet tricks.
  • 0:13
    We've learned a lot about template inheritance and blocks.
  • 0:15
    Now let's make things a bit more interesting.
  • 0:21
    We created a title block in our layout
  • 0:23
    so that the individual pages could control the page title.
  • 0:27
    If a page has a title block, it replaces the page title entirely.
  • 0:31
    If it has no title block, then the default title is used.
  • 0:36
    Let me change the title block to be a little more interesting.
Loading ...

Twig Tricks and HTML Escaping


In this tutorial we're going to play with some extra nice things you can do with Twig. We're going to get expert control of our blocks with the block function, work with concatenating strings, controlling our whitespace, and using undefined variables with the default filter. We'll wrap things up with a look at escaping HTML. Whenever you render content that may have been filled in by the user, you need to escape it. This prevents people from writing HTML tags that you don’t want or, worse, JavaScript code that could be used for cross-site scripting attacks.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.