diff --git a/README.md b/README.md index 3db26c8..b0708b5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ A calm and clutter-free theme for VSCode, originally based on [DuoTone](https:// ## Examples -### JavaScript +### JavaScript/JSX ![](https://raw.githubusercontent.com/felixgirault/grapes-theme/master/examples/javascript.png) + +### CSS/Sass + +![](https://raw.githubusercontent.com/felixgirault/grapes-theme/master/examples/sass.png) + +### PHP + +![](https://raw.githubusercontent.com/felixgirault/grapes-theme/master/examples/php.png) diff --git a/examples/javascript.png b/examples/javascript.png index 9d883c2..14f7d37 100644 Binary files a/examples/javascript.png and b/examples/javascript.png differ diff --git a/examples/php.php b/examples/php.php index 41626f9..299aee3 100644 --- a/examples/php.php +++ b/examples/php.php @@ -1,49 +1,39 @@ logger = $logger; - } + /** + * A regex to identify variables in a template. + * + * @var string + */ + const variablePattern = '~\{?:(?[a-z0-9_]+)\}?~i'; - /** - * Executes the middleware. - * - * @param ServerRequestInterface $request - * @param ResponseInterface $response - * @param callable $next - * - * @return ResponseInterface - */ - public function __invoke( - ServerRequestInterface $request, - ResponseInterface $response, - callable $next - ) { - $response = $next($request, $response); - $path = $request->getUri()->getPath(); - $date = date('c'); + /** + * Compiles a template with variables. + * + * @param string $template Template. + * @param array $variables Variables. + * @return string Compiled template. + */ + public static function compile($template, array $variables) { + $compile = function ($matches) use ($variables) { + $name = $matches['variable']; - $this->logger->info("$date: Accessed $path"); + return isset($variables[$name]) + ? $variables[$name] + : ''; + }; - return $response; - } + return preg_replace_callback( + self::variablePattern, + $compile, + $template + ); + } } diff --git a/examples/php.png b/examples/php.png new file mode 100644 index 0000000..82943f8 Binary files /dev/null and b/examples/php.png differ diff --git a/examples/sass.png b/examples/sass.png new file mode 100644 index 0000000..98fc939 Binary files /dev/null and b/examples/sass.png differ diff --git a/examples/sass.scss b/examples/sass.scss index 5aa647c..76792cc 100644 --- a/examples/sass.scss +++ b/examples/sass.scss @@ -15,5 +15,6 @@ } .Article-body { + @include mixin(); padding: 1.5rem; }