Giter Club home page Giter Club logo

stringbladecompiler's Introduction

String Blade Compiler

Render Blade templates from string value.

This is a fork from https://github.com/Flynsarmy/laravel-db-blade-compiler which uses Elequent model to pass in a template.

I have reworked it to allow for a generic array of the required fields to generates and return a compiled view from a blade-syntax template.

Version

This version 1 is for Laravel 4.2, version 2 is for Laravel 5.

Version 3 is a complete rewrite, for Laravel 5.1

Installation

For composer install,

Add the package to composer.json:

"require": {		
	"wpb/string-blade-compiler": "1.*"
},

On packagist.org at https://packagist.org/packages/wpb/string-blade-compiler

Or from the console using require: composer require "wpb/string-blade-compiler:1.*"

Add the ServiceProvider to the providers array in app/config/app.php

'Wpb\StringBladeCompiler\StringBladeCompilerServiceProvider',

There is no need to add a Facade to the aliases array as the service provider it is included automatically in the package's ServiceProvider.

Usage

This package offers a StringView facade with the same syntax as View but accepts a Array or Array Object instance instead of path to view.

return StringView::make(
                        array(
                            // this actual blade template
                            'template'  => '{{ $token1 }}',
                            // this is the cache file key, converted to md5
                            'cache_key' => 'my_unique_cache_key',
                            // timestamp for when the template was last updated, 0 is always recompile
                            'updated_at' => 1391973007
                        ),
                        array(
                            'token1'=> 'token 1 value'
                        )
                );

Also allows for Blade::extend, example :

                        // allows for @continue and @break in foreach in blade templates
                        StringView::extend(function($value)
                        {
                          return preg_replace('/(\s*)@(break|continue)(\s*)/', '$1<?php $2; ?>$3', $value);
                        });

License

string-blade-compiler is open-sourced software licensed under the MIT license

stringbladecompiler's People

Contributors

terreporter avatar rrrhys avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.