Code Monkey home page Code Monkey logo

larpug's Introduction

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>';

larpug's People

Contributors

acidjazz avatar droooney avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

larpug's Issues

Consider speaking about larpug limitations

Hi,

Maybe you know https://github.com/BKWLD/laravel-pug exists and is now based on Phug, a PHP port of pug.

It's a different approach of yours, I can identify two major advantage/limitation for each:

  • you use the native pug engine by default (so it benefit the updates of the original project), in laravel-pug, it is also possible by setting an option, but by default it use the PHP engine.
  • laravel-pug does not need some port to be listened and does not serialize the data. For example in laravel-pug, you can pass User object, Carbon/DateTime object in a non-destructive way, and you will still be able to manipulate them in your templates:
p=myDate.diffForHumans()

That is the major benefit of a PHP engine in my opinion and it's particularly relevant in Laravel context.

I would consider talking about your alternative on laravel-pug and I think you should also inform in your README about other existing solution and, advantages and limitations of them.

What do you think about it?

PS: You could avoid listening the port 4242 (it would be sad that someone that already use this port in his server to not be able to use your project) by using pug-cli, it's what I used to provide native support (see pugjs option of https://github.com/pug-php/pug).

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.