jawee / language-blade

Blade (Laravel) templating support in Atom
https://atom.io/packages/language-blade
Other
51 stars 21 forks source link

Add blade-markdown support #90

Closed nallenscott closed 4 years ago

nallenscott commented 4 years ago

Add support for hybrid Blade/Markdown syntax used by static site generators like Jigsaw.

Ingramz commented 4 years ago

Thanks for the pull request!

The documentation is rather sparse on the details how this works, would it be possible for you to provide examples of such files, so that this could be tested / validated?

nallenscott commented 4 years ago

As far as Atom is concerned, they are syntactically identical to a Blade or Markdown template. It's not a hybrid language, just a file that contains both Blade and Markdown. Jigsaw processes the file for Blade, then uses the suffix to determine if the file contains another supported format (e.g., .md, .json, .xml). There are plenty of examples in the tightenco/jigsaw test sources.

Ingramz commented 4 years ago

Any idea whether PHP syntax still works in those files? Laravel's blade includes everything between <?php and ?> as-is to the output and turns most of blade syntax to also equivalent code in PHP*.

**<?php echo 'bold text'; ?>**

Would this be equivalent to this in terms of final result?

**bold text**
nallenscott commented 4 years ago

Any executable code in blade.md is escaped. Your example results in <strong><?php echo 'bold text'; ?></strong>.

nallenscott commented 4 years ago

It looks like Blade offers a directive for embedding PHP in your templates. I wasn't aware of this and haven't tested it, but I'm assuming it won't highlight properly since I didn't include any PHP patterns in my grammar...

nallenscott commented 4 years ago

@php // @endphp blocks are also escaped, so I think we can safely ignore PHP in blade.md files.

Users will also need to add source.gfm.blade to the list of grammars in the Atom markdown preview package in order to use the Markdown Preview command on these files.

Ingramz commented 4 years ago

Thanks for the heads-up. I'll give this another try during the weekend and likely then also merge and do a release.

Ingramz commented 4 years ago

The PHP grammar was broken because of the missing reference to moved code in the repository. Otherwise it is looking good enough and is flexible for expansion in the future. Thanks again for the pull request.