Articles

Տարբեր էլեմենտների համար ո՞ր կաղապարն է գեներացնում նշված HTML-ի կոդը, իմանալու համար կարող եք օգտագործել Twig-ի ներառված debug տարբերակը։ Այս կարգավորումը կցուցադրի HTML-մեկնաբանություններ՝ համատեղ տեսանելի ելքի հետ, որտեղ նշված կլինեն օգտագործվող թեմաների hook-երը, առաջարկվող կաղապարային ֆայլերի անունները, ինչպես նաև հստակ կոշտ կոդով նշված կլինի Twig ֆայլը, որը պատասխանատու է տվյալ հատվածի ռենդերի համար։

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Twig-ում ֆիլտրերը կարող են օգտագործվել փոփոխականների փոփոխման համար։ Ֆիլտրերը փոփոխականից բաժանվում են "|" նշանով։ Դրանք կարող են ունենալ ընտրովի արգումենտներ փակագծերում։ Կարելի է կապել մի քանի ֆիլտրեր։ Առաջին ֆիլտրի արդյունքը փոխանցվում է հաջորդին։
Օրինակ՝
{{ content|safe_join(", ")|lower }}
Միգուցե անհրաժեշտ լինի սկզբում էլեմենտը դ_render անել, այնուհետև ֆիլտրել․

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Twig տրամադրում է մի շարք հարմար ֆունկցիաներ, որոնք կարելի է օգտագործել անմիջապես կաղապարներում։
Drupal միջուկը ավելացնում է մի քանի օգտվողային ֆունկցիաներ, որոնք հատուկ են Drupal-ին։ Դրանք սահմանված են TwigExtension դասում։

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

«Twig»-ի պաշտոնական փաստաթղթից՝ «Մակրոներն ընդհանրելի են սովորական ծրագրավորման լեզուների ֆունկցիաների հետ։ Դրանք օգտակար են հաճախ օգտագործվող HTML իդիոմները բազմակի օգտագործման տարրերում տեղավորելու համար, որպեսզի չկրկնվեն»։
{% macro input(name, value, type, size) %} <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" /> {% endmacro %}
Մակրոները տարբերվում են PHP-ի բնիկ ֆունկցիաներից մի քանի ուղղություններով՝

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Դրա համար, որպեսզի Drupal 8 թեման հնարավորինս արդյունավետ լինի և Twig կաղապարներում ավելի շատ հարմարեցման հնարավորություններ ունենաք, հետևեք հետևյալ խորհուրդներին․

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Ընդհանուր գաղափարն Drupal 8-ում այն է, որ ցանկանում եք խուսափել HTML-ի ուղղակի ստեղծումից ձեր օգտատերային մոդուլի PHP կոդում։ Դուք ուզում եք, որ դա կատարվի Twig կաղապարներով։ Նոր Twig կաղապարներ ստեղծելու համար ձեր մոդուլում, կատարեք հետևյալ քայլերը։

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Twig կաղապարները կարող են ընդլայնվել հետևյալ սինտաքսով՝
{% extends 'html.twig' %}
Լրացուցիչ տեղեկություններ կարելի է գտնել https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts հասցեով

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Ենթաթեմաներ, ինչպես ցանկացած այլ թեմա, առանձնանում են մեկ տարբերությամբ՝ նրանք ժառանգում են իրենց ծնողական թեմայի ռեսուրսները։ Ենթաթեմաների և նրանց ծնողական թեմաների միջև կապող շղթայի մեջ սահմանափակումներ չկան։ Ենթաթեման կարող է լինել մյուս ենթաթեմայի երեխան, և այն կարող է կազմակերպվել ու ճյուղավորվել ինչպես ձեզ անհրաժեշտ է։ Սա տալիս է ենթաթեմաներին մեծ հնարավորություններ։
Ենթաթեմա ստեղծելու համար ներկայացրեք այն ինչպես ցանկացած այլ թեմա և հայտարարեք

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.


Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.

Նշեք բոլոր CSS դասերի ընտրիչները, որոնք առկա են Drupal 8 Classy թեմայում:
ֆորմատ՝
.foo { }
.foo-bar { }
ֆայլի անունը.html.twig / ֆայլի անունը.css
Twig — Կան CSS ընտրիչներ Classy թեմայում՝
LAYOUT
Body
.user-logged-in { }
.path-frontpage { }
.path-[root_path] { }
.node--type-[node_type] { }
.db-offline { }
.visually-hidden { }
.focusable { }
.skip-link { }
ֆայլ՝ html.html.twig

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.