Vim syntax highlighting for Blade templates.

Related tags

Laravel vim-blade
Overview

vim-blade

Vim syntax highlighting for Blade templates (Laravel 4+).

This plugin contributes to vim-polyglot language pack.

Installation

Using vim-plug vim-plug.

Plug 'jwalton512/vim-blade'

Using pathogen pathogen.vim.

cd ~/.vim/bundle
git clone git://github.com/jwalton512/vim-blade.git

Configuration

Because Blade allows you to define your own directives, you can let the plugin know about them through some variables. Examples:

" Define some single Blade directives. This variable is used for highlighting only.
let g:blade_custom_directives = ['datetime', 'javascript']

" Define pairs of Blade directives. This variable is used for highlighting and indentation.
let g:blade_custom_directives_pairs = {
      \   'markdown': 'endmarkdown',
      \   'cache': 'endcache',
      \ }

Contributing

Pull requests are greatly appreciated. Please be certain to include a test where applicable (test.blade.php). You may test locally by using vim -u vimrc.

Want to buy me a coffee?

Flattr this git repo

Comments
  • Php and html indentation breaks when using html5 plugin

    Php and html indentation breaks when using html5 plugin

    When editing a blade file the filetype becomes BLADE but then auto indentation for HTML and PHP (within <?php, ?> tags no longer works as spected).

    Should blade indent bring in html and php indent files?

    For proper html autoindent inside php files i'm using this plugin:

                      Plug 'captbaritone/better-indent-support-for-php-with-html'
    
    bug 
    opened by alx741 9
  • Reference vim-polyglot language pack

    Reference vim-polyglot language pack

    Hey Jason

    Thank you for an awesome syntax for vim! I'd like to discuss something with you:

    1. Long time ago I've selected your syntax plugin as a part of vim-polyglot language pack. It is regularly updated and developed for more than 2 years now. I'd like to ask you to link to it, so all language packs and vim-polyglot can gain popularity as a community :) I'm sending a pull-request with one possible reference in the README, but maybe you want to write one by yourself? Vim-polyglot already lists and links to your plugin.
    2. Vim-polyglot is an open source project, but I'd like to make it a community effort. Maybe you'd like to become a contributor to it? You'd have commit access so you could fix any issues vim-polyglot introduces, release updates, and propose/evaluate/develop other language packs.

    Thank you for considering both requests.

    Regards, Adam

    opened by sheerun 7
  • Indent issue

    Indent issue

    Hi,

    I have a problem with indentation on *.blade.php files. I was using this trick based on the following issue https://github.com/xsbeats/vim-blade/issues/1

    autocmd BufNewFile,BufRead *.blade.php set ft=html | set ft=phtml | set ft=blade " Fix blade auto-indent
    
    @foreach ($articles as $article)
       <h1>{{ $article->title }}</h1>
       <p>{{ $article->content }}</p>#
    |
    @endforeach
    

    When it should be

    @foreach ($articles as $article)
       <h1>{{ $article->title }}</h1>
       <p>{{ $article->content }}</p>#
       |
    @endforeach
    

    The following command outputs:

    :set ft?
    filtetype=blade
    

    How to solve it?

    Regards,

    opened by jrean 7
  • Test case idea

    Test case idea

    Highlighting plugins seem like the kind of project which could really use test cases since I imagine they're pretty susceptible to regressions.

    I figure it might be pretty easy to build a test case for a current version by using the :TOhtml function in vim and dumping that in a file, then the test case can check the current output against the saved. Once satisfied that a new change doesn't regress anything, the new test blade code is added and the HTML regenerated.

    Just an idea.

    enhancement 
    opened by tremby 7
  • Auto indent issue

    Auto indent issue

    Trying to use this plugin to develop in Laravel. Syntax looks nice, but the indentation doesn't seem to work properly. Given this sample code below, when I press o at the cursor # the new line | starts at the very beginning not at the proper indentation level.

    @foreach ($articles as $article)
       <h1>{{ $article->title }}</h1>
       <p>{{ $article->content }}</p>#
    |
    @endforeach
    

    When it should be:

    @foreach ($articles as $article)
       <h1>{{ $article->title }}</h1>
       <p>{{ $article->content }}</p>#
       |
    @endforeach
    

    This happens at any indentation level. Any ideas how to fix it?

    opened by elclanrs 6
  • Add support to eclim indent

    Add support to eclim indent

    Currently indentation is based on the function HtmlIndent which is the default.

    But there are plugins that add their own indentation. The eclim is one of those.

    It is good to give the user option to continue using HTML and PHP indenting of your favorite plugin and only add the Blade indentation.

    I added a check to see which base indentation should follow, if none is defined or is not valid, will use the default HtmlIndent. It also checks if the required function exists.

    For now I only know eclim, but if someone inform other cases like this, it will be easy to add.

    This change does not alter the operation of anyone, even if you use the eclim.

    If someone has the eclim and want to use the standard indentation eclim and only add the indentation blade, just add in your .vimrc the following line:

    let g:BladeIndentBase = 'eclim'

    The main difference in eclim indentation is that it increases the indentation when there is line break between attributes.

    Default:

    <input name="example"
    value="example" />
    

    Eclim:

    <input name="example"
            value="example" />
    

    It was this difference that I realized I had something was out of the pattern of other files.

    opened by jn-jairo 5
  • Too long lines breaks blade highlight

    Too long lines breaks blade highlight

    I have the following piece of code in one of my blade files. For some reason, the first line of code breaks the highlight as seen on the screenshot

    <button class="navbar-toggler"  data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
        <span class="navbar-toggler-icon"></span>
    </button>
    

    captura de pantalla 2018-08-26 a la s 18 53 10

    If I break the first line in two lines, the higlight works as expected.

    opened by lcjury 4
  • Line outdents when using -> inside Blade tag

    Line outdents when using -> inside Blade tag

    Example file (named test.blade.php):

    <div>
        |
    </div>
    

    Pipe shows where to position the cursor. In insert mode, type: {{ $foo->

    Upon hitting the > key, the line will outdent.

    I'm using the latest version of NeoVim and vim-blade on Arch Linux. The ft is indeed blade and I don't think there's anything in my config which could be messing with this.

    opened by RyanDwyer 4
  • Add missing characters to 'iskeyword'

    Add missing characters to 'iskeyword'

    My previous commit (fc9fceb) broke the highlighting of keywords with numbers in it (e.g. h1-h6). I changed it to the default value of iskeyword plus @-@

    opened by adriaanzon 4
  • Integration with eclim indent

    Integration with eclim indent

    The old code overwrites the indentation of eclim plugin.

    With these changes, if the indentation of eclim is available, this will be used, otherwise it continues using the default indentation.

    opened by jn-jairo 4
  • Add @props directive to the default supported directives

    Add @props directive to the default supported directives

    Overview

    This PR resolves #74 by adding the @props directive to the list of default supported directives.

    The @props directive was supplied by Laravel as part of their Blade component upgrade (docs here) as a way to pass data into anonymous components. For anyone unfamiliar, anonymous components are Blade components that are not backed by a PHP class and only consist of a Blade file.

    Since Laravel has added this directive directly into the framework, I think we ought to have it in this plugin as well!

    Additions

    • Adds the @props directive to syntax/blade.vim
    • Adds a test to test.blade.php

    Other Notes

    I added the @props directive to the top of the test.blade.php file because, typically, that's where the directive would go in everyday use.

    I'm fairly certain that I added the directive to the correct spot in the syntax file, as it was working when I tested using the provided blade testing file, but I'm happy to move it somewhere else in the list if that would be preferable.

    Thank you again for maintaining this package! It's an integral part to my Laravel development workflow, so I really appreciate it.

    opened by alexandersix 0
  • Add `@props` directive to the supported directives list

    Add `@props` directive to the supported directives list

    From what I can tell, it seems that the @props directive that is used by Laravel to make Blade Components (here) isn't supported by default at the moment.

    Since this is a Laravel-supported directive, I think it would make sense to add into the plugin. Right now, I can get around it fairly easily by using the vim configurations for custom directive (thanks for adding that, by the way–it's super helpful), but it would be nice to not have to worry about adding @props to the list myself.

    I'm happy to take a stab at this issue, but I'm going out of town shortly for about a week, so I figured that I'd go ahead and open an Issue in case anyone wanted to work on this while I'm away from my computer.

    Also, as always, if this isn't an issue, please let me know!

    Thanks for supporting this plugin! It's a huge part of my vim workflow for Laravel development 👍🏻

    opened by alexandersix 0
  • Accessing an object's property inside of an html tag causes highlighting to get confused

    Accessing an object's property inside of an html tag causes highlighting to get confused

    I'm using

    <option @if($prod->key) selected @endif value="yes">Yes</option>
    

    and it gets confused when it encounters > and the highlighting is screwed up until the closing </option> tag.

    When testing this, I realized that it has trouble with the data keyword as well...but that just might be from a conflict with html5.vim. Come to think of it, maybe it all has to do with the fact that I'm using othree/html5.vim? Does this affect anyone else?

    screen shot 2018-03-22 at 11 48 53 am

    bug 
    opened by endoped 1
  • Indentation and syntax borked in Laravel 5.5

    Indentation and syntax borked in Laravel 5.5

    I just pulled a fresh installation of Laravel and took a look in the default welcome.blade.php file.

    Hit gg V G = and ended up with the following results.

    Before: image

    After: image

    Clearly, the indentation is all wrong and the syntax highlighting doesn't seem to recognize the new custom if-conditionals (@auth and its closing tag @endauth) - the latter seemingly being the root of the problem.

    opened by superDuperCyberTechno 3
Owner
Jason Walton
Jason Walton
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021
Use Blade templates without the full Laravel framework

blade Use Laravel Blade templates as a standalone component without the full Laravel framework Full documentation is available at http://duncan3dc.git

Craig Duncan 138 Dec 7, 2022
API Blueprint Renderer for Laravel, customizable via Blade templates

API Blueprint Renderer for Laravel This Laravel package Blueprint Docs renders your API Blueprint. It comes with a standard theme that you can customi

Michael Schmidt-Voigt 225 Sep 16, 2022
Create inline partials in your Blade templates with ease

Create inline partials in your Blade templates with ease. This package introduces a new @capture directive that allows you to capture small parts of y

Ryan Chandler 27 Dec 8, 2022
A library for using Laravel Blade templates in WordPlate.

A library for using Laravel Blade templates in WordPress/WordPlate. Installation Require this package, with Composer, in the root directory of y

null 28 Nov 28, 2022
Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views

Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views. In all essence, it's a collection of useful utilities, connecting the dots between different parts of the TALL stack. It was made for Blade, Laravel's powerful templating engine.

Blade UI Kit 1.2k Jan 5, 2023
Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline.

Blade Snip Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline: <div class="products"> @snip('pr

Jack Sleight 18 Dec 4, 2022
Retrieve the EC2 Metadata using Laravel's eloquent syntax.

Laravel EC2 Metadata Retrieve the EC2 Metadata using Laravel's eloquent syntax. ?? Supporting If you are using one or more Renoki Co. open-source pack

Renoki Co. 4 Dec 27, 2021
Simple transactional email classes/templates for Laravel 5 mailables

Tuxedo Tuxedo is an easy way to send transactional emails with Laravel's Mail classes, with the templates already done for you. Contents Installation

Tom Irons 92 May 27, 2022
Extend Kirby’s templates with a powerful layout system

Kirby Layouts plugin This plugin extends Kirby’s templates with a powerful layout system. Installation Download Download and copy this repository to /

Kirby 3 39 Dec 28, 2022
Mailing platform with templates and logs included.

MailCarrier User-friendly, API-ready mail platform with templates and logs. Design global layouts, compose your template, preview your emails and send

MailCarrier 18 Dec 14, 2022
A package to easily make use of Iconic icons in your Laravel Blade views.

Blade Iconic A package to easily make use of Iconic icons in your Laravel Blade views. For a full list of available icons see the SVG directory. Iconi

Malik Alleyne-Jones 17 Aug 25, 2022
A package to easily make use of Simple Icons in your Laravel Blade views.

Blade Simple Icons A package to easily make use of Simple Icons in your Laravel Blade views. For a full list of available icons see the SVG directory.

UB Labs 12 Jan 17, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Tina Hammar 7 Nov 23, 2022
Cache chunks of your Blade markup with ease. 🔪

Blade Cache Directive Cache chunks of your Blade markup with ease. Installation You can install the package via Composer: composer require ryangjchand

Ryan Chandler 155 Dec 10, 2022
Storybook for Laravel Blade 🚀

Blast — Storybook for Laravel Blade ?? What is Blast? Blast is a low maintenance component library using Storybook Server, built to integrate into you

AREA 17 182 Jan 3, 2023
Cagilo - a set of simple components for use in your views Laravel Blade.

Cagilo - a set of simple components for use in your views Laravel Blade. Official Documentation Documentation for Cagilo can be found on its we

Cagilo 151 Dec 6, 2022
Useful blade components and functionality for most Laravel projects.

laravel-base Note: Package is still in early stages of development, so functionality is subject to change. LaravelBase is a package I've created to pr

Randall Wilk 3 Jan 16, 2022
Create Laravel views (blade template) using 'php artisan' command-line interface

About LaraBit Have you ever wonder to create Laravel views (Blade Templates) using the same type of artisan commands that you usually use to create ne

Ragib MRB 5 Oct 15, 2021