acidjazz / larpug by acidjazz

Adds the power of Pug to Laravel
542
42
5
Package Data
Maintainer Username: acidjazz
Maintainer Contact: acidjazz@gmail.com (Kevin Olson)
Package Create Date: 2016-07-22
Package Last Update: 2017-10-19
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:23:54
Package Statistics
Total Downloads: 542
Monthly Downloads: 3
Daily Downloads: 0
Total Stars: 42
Total Watchers: 5
Total Forks: 5
Total Open Issues: 3

Allows you to use native Pug (formerly Jade) seamlessly in Laravel 5 and Lumen

Total Downloads Latest Stable Version License Build Status Dependency Status codecov

Join the chat at https://gitter.im/acidjazz/larpug

Requirements

Installation

Require this package with Composer

composer require acidjazz/larpug

Install the needed node modules to run pug

npm i --prefix vendor/acidjazz/larpug/node/

Laravel

Once Composer has installed or updated your packages you need to register larpug with Laravel itself. Open up config/app.php and find the providers key, towards the end of the file, and add 'larpug\LarpugServiceProvider', to the end:

'providers' => [
  ...
    Larpug\ServiceProvider::class,
],

Lumen

For usage with Lumen, add the service provider in bootstrap/app.php.

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

Usage

Using this is exactly the same way as using Blade templates, place your pug files in your views folder (usually in resources/views) and render them using view()

namespace App\Controllers;

class Pages extends Controller
{
  public function index()
  {
    return view('pages.index', ['name' => 'kevin', 'title' => 'test title']);
  }

}

This will look for resources/views/pages/index.pug

doctype
html(lang='en')
  head
    title Title: #{self.title}
  body
    .page.index 
      .name=self.name

Which will render something like

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Title: test title </title>
  </head>
  <body>
    <div class="page index">
      <div class="name">Kevin</div>
    </div>
  </body>
</html>';