All Projects → BKWLD → Laravel Pug

BKWLD / Laravel Pug

Licence: mit
Pug view adapter for Laravel and Lumen

Projects that are alternatives of or similar to Laravel Pug

Gulp Pug Sass Seed
🍹 A Pug and Sass starter project using gulp for task automation.
Stars: ✭ 84 (-35.38%)
Mutual labels:  pug, jade
Wordless
All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
Stars: ✭ 1,374 (+956.92%)
Mutual labels:  pug, jade
Larafast Fastapi
A Fast Laravel package to help you generate CRUD API Controllers and Resources, Model.. etc
Stars: ✭ 91 (-30%)
Mutual labels:  laravel, lumen
Expug
Pug templates for Elixir
Stars: ✭ 74 (-43.08%)
Mutual labels:  pug, jade
Vim Laravel
Vim support for Laravel/Lumen projects
Stars: ✭ 128 (-1.54%)
Mutual labels:  laravel, lumen
Laravel Sqs Fifo Queue
Adds a Laravel queue driver for Amazon SQS FIFO queues.
Stars: ✭ 75 (-42.31%)
Mutual labels:  laravel, lumen
Laravel Aspect
aspect oriented programming Package for laravel framework
Stars: ✭ 98 (-24.62%)
Mutual labels:  laravel, lumen
Ines Io
⚡️ Source of my website and blog (Harp, Jade, Sass, JavaScript)
Stars: ✭ 38 (-70.77%)
Mutual labels:  pug, jade
Node.js Bootstrap Starter Template
Node.js, Express, Pug, Twitter Bootstrap, Starter Template
Stars: ✭ 107 (-17.69%)
Mutual labels:  pug, jade
Taobao Top Client
Taobao top client(SDK) for laravel
Stars: ✭ 105 (-19.23%)
Mutual labels:  laravel, lumen
Laravel Health Check
A package for checking the health of your Laravel & Lumen applications
Stars: ✭ 59 (-54.62%)
Mutual labels:  laravel, lumen
Vue Lumen Starter
😎 VueJs & Lumen Api Starter.
Stars: ✭ 116 (-10.77%)
Mutual labels:  laravel, lumen
Kickstarts
💻 No setup, just development!
Stars: ✭ 57 (-56.15%)
Mutual labels:  laravel, lumen
Laravel Url Shortener
Powerful URL shortening tools in Laravel
Stars: ✭ 80 (-38.46%)
Mutual labels:  laravel, lumen
Http Basic Auth Guard
HTTP Basic Auth Guard for Lumen 5.x
Stars: ✭ 39 (-70%)
Mutual labels:  laravel, lumen
Pug Sass Boilerplate Starter Kit
A Front-end template for building web apps or sites using Pug(Jade) and Sass
Stars: ✭ 92 (-29.23%)
Mutual labels:  pug, jade
Lumen Api Demo
Lumen rest api demo with Dingo/Api, JWT, CORS, PHPUNIT
Stars: ✭ 856 (+558.46%)
Mutual labels:  laravel, lumen
Freshdesk Laravel
Freshdesk Service Provider for Laravel 5 and Lumen
Stars: ✭ 14 (-89.23%)
Mutual labels:  laravel, lumen
Larasupport
📦 Adds Laravel Packages Support to Lumen and Vendor Publish Artisan Command.
Stars: ✭ 104 (-20%)
Mutual labels:  laravel, lumen
Jade Html5 Boilerplate
HTML5 Boilerplate ported to Jade. Great as a drop and go markup skeleton for Express apps.
Stars: ✭ 111 (-14.62%)
Mutual labels:  pug, jade

Laravel Pug

Packagist Build Status StyleCI codecov Code Climate License

A small package that adds support for compiling Pug (Jade) templates to Laravel via Pug.php (see complete documentation). Both vanilla php and Blade syntax is supported within the view.

This is the documentation for the ongoing version 2.0. Click here to load the documentation for 1.11

Installation

First you need composer if you haven't yet: https://getcomposer.org/download/

Now open a terminal at the root of your Laravel project. If it's a new project, create it with: composer create-project --prefer-dist laravel/laravel my-new-project (replace my-new-project with your own project name, see the documentation for further information)

Then run:

composer require bkwld/laravel-pug

Usage

Route::get('/', function () {
    return view('my-page');
});

Will now try to load views/my-page.pug first, or views/my-page.blade.pug or fallback to the default blade engine loading views/my-page.blade.php.

As with Blade, you can pass variables to your view:

Route::get('/', function () {
    return view('my-page', [
        'user' => Auth::user(),
        'messages' => ['Hello', 'Bye'],
    ]);
});

Any file with the extension .pug will be compiled as a pug template. Laravel Pug also registers the .pug.blade which also compile blade code once Pug code has been compiled; but we highly recommend you to use the clean and standard extension .pug that will be recognized by most systems. It compiles your Pug templates in the same way as Blade templates; the compiled template is put in your storage directory. Thus, you don't suffer compile times on every page load.

In other words, just put your Pug files in the regular views directory and name them like whatever.pug. You reference them in Laravel like normal such as view('home.whatever') for resources/views/home/whatever.pug.

The Pug view files can work side-by-side with regular PHP views.

Use Blade in Pug templates

This feature is designed for transition purpose, since every blade features are available in pug, you would not need both.

To use Blade templating within your Pug, just name the files with .blade.pug extensions.

Read more

Be aware that this mode will first render your template with pug, then give the output to render to blade, it means your template must have a valid pug syntax and must render a valid blade template. This also means blade directives are only available through pug text output, see the example below:

| @if ($one === 1)
div $one = 1
| @endif
p {{ $two }}

If you render this with the following values: ['one' => 1, 'two' => 2], you will get:

<div>$one = 1</div>
<p>2</p>

PS: note that you would get the same output with the following pure pug code:

if one === 1
  div $one = 1
p=two

Use in Lumen

Register the service in bootstrap/app.php (Register Service Providers section is the dedicated place):

$app->register(Bkwld\LaravelPug\ServiceProvider::class);

Then you can use it with view():

$router->get('/', function () use ($router) {
    // will render resources/views/test.pug
    return view('test', [
        'name' => 'Bob',
    ]);
});

Configuration

All Pug.php options are passed through via a Laravel config array file you can edit /config/laravel-pug.php

If for any reason, the config file is missing, just run the following command: php artisan vendor:publish --provider="Bkwld\LaravelPug\ServiceProvider"

Extending Layouts / Include Sub-views

Default root directory for templates is resources/views, so from any template any deep in the directory, you can use absolute paths to get other pug files from the root: extends /layouts/main will extends the file resources/views/layouts/main.pug, include /partial/foo/bar, will include resources/views/partial/foo/bar.pug. You can use the basedir option to set the root to an other directory. Paths that does not start with a slash will be resolved relatively to the current template file.

History

Read the Github project releases for release notes.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].