Commit b448dadd authored by Matt's avatar Matt

Allow inline styles

parent 1d84beb1
Pipeline #52188668 failed with stages
in 3 minutes and 15 seconds
......@@ -14,6 +14,7 @@ class Container implements \JsonSerializable
private $favicon;
private $title;
private $css;
private $inline_styles;
private $scripts;
public function __construct(
......@@ -25,6 +26,7 @@ class Container implements \JsonSerializable
?string $favicon = null,
?string $title = null,
?array $css = [],
?array $inline_styles = [],
?array $scripts = []
) {
$this->emmet = $emmet;
......@@ -35,6 +37,7 @@ class Container implements \JsonSerializable
$this->favicon = $favicon;
$this->title = $title;
$this->css = $css;
$this->inline_styles = $inline_styles;
$this->scripts = $scripts;
}
......@@ -49,6 +52,7 @@ class Container implements \JsonSerializable
'favicon' => $this->getFaviconLink(),
'title' => $this->getTitle(),
'css' => $this->getCssLinks(),
'inline_styles' => $this->getInlineStyles(),
'scripts' => $this->getScriptLinks(),
];
}
......@@ -68,6 +72,11 @@ class Container implements \JsonSerializable
return $this->css ?: [];
}
public function getInlineStyles(): array
{
return $this->inline_styles ?: [];
}
public function getScriptLinks(): array
{
return $this->scripts ?: [];
......
......@@ -25,8 +25,13 @@ class Resolver
$value = $parts[1] ?? null;
if ($value && filter_var($value, FILTER_VALIDATE_URL) !== false) {
${$link_prefix}[] = $value;
if ($value) {
if (filter_var($value, FILTER_VALIDATE_URL) !== false) {
${$link_prefix}[] = $value;
} else {
$inline_styles[] = $value;
}
unset($records[$key]);
}
}
......@@ -66,6 +71,7 @@ class Resolver
'title' => $title ?? null,
'css' => $css ?? null,
'inline_styles' => $inline_styles ?? null,
'scripts' => $script ?? null,
]);
}
......
......@@ -31,6 +31,10 @@
<link rel="stylesheet" type="text/css" href="{{ link }}">
{% endfor %}
{% for css in records.getInlineStyles() %}
<style type="text/css">{{ css }}</style>
{% endfor %}
{% for link in records.getScriptLinks() %}
<script type="text/javascript" src="{{ link }}"></script>
{% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment