Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude code blocks from Blade compilation #206

Merged
merged 1 commit into from
Jun 13, 2020
Merged

Exclude code blocks from Blade compilation #206

merged 1 commit into from
Jun 13, 2020

Conversation

Jhnbrn90
Copy link

@Jhnbrn90 Jhnbrn90 commented Mar 29, 2020

The issue

This PR addresses issue #168, in which an Exception is thrown when using Blade syntax within code blocks. This issue arises from the fact that currently the whole page is rendered through a Blade compiler, including the code blocks.

What has been done

  • Added compileBlade method, in which code blocks are first stripped from the documentation content after which compilation is performed and finally the stubbed out code blocks are replaced by their original contents.
  • Stored matching and replacement regex patterns in config.
  • Added a PHPunit test, asserting blade syntax is not compiled within code blocks.

Example of code block with Blade syntax

Schermafbeelding 2020-03-29 om 14 28 48

Please let me know if you have any suggestions or additions.

PS: currently the tests are failing, see #205.

@Jhnbrn90 Jhnbrn90 changed the base branch from master to 1.0 March 31, 2020 19:13
@Jhnbrn90 Jhnbrn90 changed the base branch from 1.0 to master March 31, 2020 19:13
@mbroadhead
Copy link

I am actually using blade directives in my code blocks. I created an @apiurl('/some/route') blade directive that generates the full url based on the current api version. Many times I show an example in curl like so:

curl @apiurl('/some/route')

With would then render as:

curl https://example.com/api/1.0/some/route

It sounds like this pull request would break what I'm doing. Can you think of an alternative to what I'm doing that would work with your pull request or could we have a config option to enable/disable your feature? Something like config('larecipe.verbatim_code_blocks') = true|false

@Jhnbrn90
Copy link
Author

Jhnbrn90 commented May 13, 2020

@mbroadhead I'm willing to do that, only if @saleem-hadad confirms plans to merge this PR at all.

@saleem-hadad saleem-hadad merged commit eb3a3f6 into saleem-hadad:master Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants