diff --git a/Dockerfile b/Dockerfile index 6a6e3de3..8a3bfe03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,8 +47,11 @@ COPY composer.json \ ./ RUN mkdir public source && \ - composer --no-interaction install --ignore-platform-reqs --classmap-authoritative --no-suggest --prefer-dist + composer --no-interaction install --ignore-platform-reqs --classmap-authoritative --no-autoloader --no-suggest --prefer-dist +COPY source/php/ source/php/ + +RUN composer --no-interaction dump-autoload --classmap-authoritative # diff --git a/composer.json b/composer.json index 64eba3a4..d833042e 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,9 @@ "autoload": { "psr-0": { "PatternLab\\": "core/src/" + }, + "psr-4": { + "Libero\\PatternLibrary\\": "source/php" } }, "require": { diff --git a/config/config.yml b/config/config.yml index 8664b2de..898e77f2 100644 --- a/config/config.yml +++ b/config/config.yml @@ -40,3 +40,5 @@ twigFilterExt: filter.php twigFunctionExt: function.php twigTagExt: tag.php twigTestExt: test.php +twigExtensions: + - Libero\PatternLibrary\Twig\MergeExtension diff --git a/gulpfile.babel.js b/gulpfile.babel.js index c66a5d36..dcf14a33 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -50,6 +50,7 @@ const buildConfig = (invocationArgs, publicRoot, sourceRoot, testRoot, exportRoo config.dir.src.fonts = `${config.sourceRoot}/fonts`; config.dir.src.templates = `${config.sourceRoot}/_patterns`; config.dir.src.js = `${config.sourceRoot}/js`; + config.dir.src.php = `${config.sourceRoot}/php`; config.dir.test.sass = `${config.testRoot}/sass`; @@ -59,6 +60,7 @@ const buildConfig = (invocationArgs, publicRoot, sourceRoot, testRoot, exportRoo config.dir.out.images = `${config.exportRoot}/images`; config.dir.out.fonts = `${config.exportRoot}/fonts`; config.dir.out.templates = `${config.exportRoot}/templates`; + config.dir.out.php = `${config.exportRoot}/php`; config.files = { src: {}, @@ -88,6 +90,7 @@ const buildConfig = (invocationArgs, publicRoot, sourceRoot, testRoot, exportRoo `${config.dir.src.templates}/**/*.twig`, `!${config.dir.src.templates}/04-pages/**/*.twig`, ]; + config.files.src.php = `${config.dir.src.php}/**/*`; config.files.src.derivedConfigs = [ `${config.dir.src.sass}/variables/**/*`, `${config.dir.src.js}/derivedConfig.json`, @@ -191,9 +194,13 @@ const exportTemplates = () => .pipe(flatten({includeParents: false})) .pipe(gulp.dest(config.dir.out.templates)); +const exportPhp = () => + gulp.src(config.files.src.php) + .pipe(gulp.dest(config.dir.out.php)); + export const exportPatterns = gulp.series( cleanExport, - gulp.parallel(exportCss, exportSass, exportSassVendor, exportImages, exportFonts, exportTemplates), + gulp.parallel(exportCss, exportSass, exportSassVendor, exportImages, exportFonts, exportTemplates, exportPhp), ); // Default diff --git a/source/_patterns/00-atoms/block/heading/heading.twig b/source/_patterns/00-atoms/block/heading/heading.twig index a0e188cd..f2337082 100644 --- a/source/_patterns/00-atoms/block/heading/heading.twig +++ b/source/_patterns/00-atoms/block/heading/heading.twig @@ -1,6 +1,6 @@ {%- import 'atoms-html' as html -%} -{%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['heading']) }) -%} +{%- set attributes = {class: 'heading'}|merge_recursive(attributes|default({})) -%} @@ -12,7 +12,7 @@ {%- block text -%} {%- if attributes.href is defined -%} - {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['heading__link']) }) -%} + {%- set attributes = {class: 'heading__link'}|merge_recursive(attributes|default({})) -%} {%- endif -%} {%- include 'atoms-link' -%} diff --git a/source/_patterns/00-atoms/block/paragraph/paragraph.twig b/source/_patterns/00-atoms/block/paragraph/paragraph.twig index 86799482..07af419f 100644 --- a/source/_patterns/00-atoms/block/paragraph/paragraph.twig +++ b/source/_patterns/00-atoms/block/paragraph/paragraph.twig @@ -1,6 +1,6 @@ {%- import 'atoms-html' as html -%} -{%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['paragraph']) }) -%} +{%- set attributes = {class: 'paragraph'}|merge_recursive(attributes|default({})) -%}

diff --git a/source/_patterns/01-molecules/content-meta/content-meta.twig b/source/_patterns/01-molecules/content-meta/content-meta.twig index 9d372b0d..0a5075e9 100644 --- a/source/_patterns/01-molecules/content-meta/content-meta.twig +++ b/source/_patterns/01-molecules/content-meta/content-meta.twig @@ -1,6 +1,6 @@ {%- import 'atoms-html' as html -%} -{%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['content-meta']) }) -%} +{%- set attributes = {class: 'content-meta'}|merge_recursive(attributes|default({})) -%}