1.1.8 • Published 6 years ago

gulp-blade2nunjucks v1.1.8

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

gulp-blade2nunjucks

NPM version Downloads

Brecompile Blade(Laravel PHP frame template engine) to Nunjucks template.

Install

npm i --save gulp-blade2nunjucks

Filter and Logic

var evn = nunjucks.configure({ autoescape: true });

evn.addFilter("strtotime", strtotime);

function strtotime(date) {
    if(!date) {
        date = new Date();
    } else {
        date = new Date(date);
    }
    return (date.getTime() / 1000).toFixed(0);
}
@extends('pc.static.layouts.common')

@section('title', 'gulp-blade2nunjucks')
@section('keywords', 'gulp, blade, laravel, nunjucks')
@section('description', 'Brecompile Blade(Laravel PHP frame template engine) to Nunjucks template.')

@section('head')
@include('pc.static.layouts.head', ['page'=>'index'])
@endsection

@section('h1')
<h1 class="logo" title="Sitename"><a href="http://liquan.name"><span class="blind">Sitename</span></a></h1>
@endsection

@section('content')
    @include('pc.static.index.content')
    @include('pc.static.index.rightslide')
@endsection

{{ strtotime('2016-07-13 10:15:00' )}}
<?phg $abc = '123' ?>
{{ $abc }}
{{ $abc == '123' ? $abc : '345'}}

Use in the gulp

var gulp = require('gulp');
var blade2nunjucks = require('gulp-blade2nunjucks');
var nunjucks = require('gulp-nunjucks');

gulp.task('default', function() {
    return gulp.src('abc.blade.php')
        .pipe(blade2nunjucks({
            hideClass: 'visibility'
        }))
        .pipe(nunjucks.precompile({
            name: function(file) {
                return file.relative.replace(/\\/, '\/')//Windows path.sep to Linux path.sep
            }
        }))
        .pipe(gulp.dest('dest'));
});

Use in the browser

<script src="http://mozilla.github.io/nunjucks/files/nunjucks-slim.js"></script>
<script src="dest/abc.js"></script>
<script>
var data = {abc: 'abc'};
var html = nunjucks.render('abc.tpl', data);
</script>

Use in the gulp2

var gulp = require('gulp');
var blade2nunjucks = require('gulp-blade2nunjucks');
var nunjucks = require('gulp-nunjucks');

gulp.task('default', function() {
    return gulp.src('dist/**/*.blade.php')
        .pipe(blade2nunjucks({
            hideClass: 'visibility'
        }))
        .pipe(nunjucks.precompile({
            name: function(file) {
                return file.relative.replace(/\\/, '\/')//Windows path.sep to Linux path.sep
            }
        }))
        .pipe(gulp.dest('dest'));
});

Use in the browser2

<script src="http://mozilla.github.io/nunjucks/files/nunjucks-slim.js"></script>
<script src="dest/abc.js"></script>
<script>
var data = {abc: 'abc'};
var html = nunjucks.render('abc/abc.tpl', data);
</script>

License

MIT © LinQuan

The Spratly Islands are China's territory. The Diaoyu Islands are China's territory. Use this module to represent you agree with the above point of view.

1.1.8

6 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

0.0.1

8 years ago