Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nsrosenqvist committed Mar 15, 2017
0 parents commit 0904853
Show file tree
Hide file tree
Showing 13 changed files with 1,141 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
dist
vendor
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Niklas Rosenqvist

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
34 changes: 34 additions & 0 deletions README.md
@@ -0,0 +1,34 @@
Blade CLI
=========

Blade CLI is a command line compiler for the Laravel Blade templating engine. You simply specify what templates you want to process as arguments.

## Installation
To install you can either clone this repo and run `composer install && composer build` or simply retrieving the latest PHAR from the [releases page](https://www.github.com/nsrosenqvist/blade-cli/releases/latest).

## Usage
`compile [options] [--] <template> (<template>)...`

### Arguments
Argument | Details
-------------|----------------------------------------------
`<template>` | The template path can be specified as a relative URI, absolute and also as how Blade natively handles include references (pages/index.blade.php vs pages.index). If supplied as a Blade reference then a base directory must be set |

### Options:
Option | Details
--------------|--------------------------------------------
`--data=DATA` | Variables passed on to the template as a JSON file/string or a PHP file returning an associative array (multiple values allowed)
`--output-dir=OUTPUT-DIR` | Output path relative from current working directory or absolute
`--base-dir=BASE-DIR` | Base directory to look for template files from. If not set, template's containing dir is assumed (multiple values allowed)
`--output-ext=OUTPUT-EXT` | When an output dir is specified you can also set what file extension the compiled template should be created with [default: "txt"]
`--dynamic-base` | Automatically add the parent directories of all templates as base directories. This requires a new Blade compiler instance for each template file which adds overhead but simplifies processing multiple templates at once and have each be a self-contained template hierarchy tree. This is not compatible with templates supplied as native Blade references
`-h, --help` | Display this help message
`-q, --quiet` | Do not output any message
`-V, --version` | Display this application version
`--ansi` | Force ANSI output
`--no-ansi` | Disable ANSI output
`-n, --no-interaction` | Do not ask any interactive question
`-v/vv/vvv, --verbose` | Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

## Development
Clone and run `composer install`. You can then run the app by executing `php bin/blade` from the root directory. To create a distributable PHAR you run `composer build`. To verify that templates are processed correctly you can run `composer test`.
20 changes: 20 additions & 0 deletions bin/blade
@@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php

require __DIR__.'/../vendor/autoload.php';

use NSRosenqvist\Blade\Console\Command;
use Symfony\Component\Console\Application;

// Create App
$application = new Application('Blade', '1.0.0');

//Add compile command
$compile = new Command\Compile();
$application->add($compile);

// Single command application
$application->setDefaultCommand($compile->getName(), true);

// Run
$application->run();
29 changes: 29 additions & 0 deletions composer.json
@@ -0,0 +1,29 @@
{
"name": "nsrosenqvist/blade-cli",
"description": "Command line version of Laravel's Blade templating engine",
"keywords": ["template compiler", "laravel blade", "terminal", "cli"],
"license": "MIT",
"homepage": "https://github.com/nsrosenqvist/blade-cli",
"authors": [
{
"name": "Niklas Rosenqvist",
"email": "niklas.s.rosenqvist@gmail.com"
}
],
"autoload": {
"psr-4": {
"NSRosenqvist\\Blade\\Console\\": "src/"
}
},
"require": {
"php": "^7.0",
"symfony/console": "^3.2",
"nsrosenqvist/blade-compiler": "^1.0.0"
},
"scripts": {
"build": "mkdir -p dist && php ./phar-composer.phar build . dist",
"test": "php bin/blade test/index.blade.php --data=test/variables.json --data=test/variables.php --data='{\"nameString\":\"John Doe\"}'",
"test:build": "php dist/blade-cli.phar test/index.blade.php --data=test/variables.json --data=test/variables.php --data='{\"nameString\":\"John Doe\"}'"
},
"bin": ["bin/blade"]
}

0 comments on commit 0904853

Please sign in to comment.