This document discusses changes to Drupal 8 theme development including:
1. Adopting SMACSS and BEM coding standards for CSS organization and naming.
2. Switching from PHP templates to the Twig templating language for improved security and easier development.
3. Changes to the theme structure including new files like .info.yml and .libraries.yml and moving templates to .html.twig files.
16. • 版型檔案不允許直接執⾏行
PHP
,讓版型更為安全。
• 版型開發者不必再學
PHP
• 預設輸出時皆會
escape
,減少
XSS
的可能性
//
This
really
shouldn't
be
allowed
to
work,
and
it
won't
in
D8.
<?php db_query('DROP TABLE {users}'); ?>
FROM PHPTEMPLATE TO TWIG
19. Here are some example of filters from the Twig
engine.
{{ 'drupal' | length }} //return: 6
{{ 'drupal' | upper }} //return: DRUPAL
{{ 'drupal is awesome' | title }} //return: Drupal Is Awesome!
{{ '<a href="#">drupal is awesome!</a>'| striptags | capitalize }}
//return: Drupal is awesome!
FILTER