Giter Club home page Giter Club logo

Comments (6)

GrahamCampbell avatar GrahamCampbell commented on July 17, 2024 2

Instead, I'd recommend moving your markdown parts to separate .md.blade.php file, then including that from a .blade.php file.

from laravel-markdown.

unnawut avatar unnawut commented on July 17, 2024 2

Just in case anyone wants to reference this. Here is what I ended up implementing (as @GrahamCampbell suggested). I'm specifically doing this for a release notes page but aiming to reuse the code for other static markdown pages in the future as well, hence the structure...

routes.php:

Route::controller('pages', 'MarkdownPagesController');

MarkdownPagesController.php:

<?php

class MarkdownPagesController extends \App\Http\Controllers\Controller
{
    public function getReleaseNotes()
    {
        return $this->markdownView('pages.release-notes');
    }

    protected function markdownView($markdownViewName)
    {
        return view('layouts.markdown', [
            'markdownViewName' => $markdownViewName,
        ]);
    }
}

views/layouts/markdown.blade.php:

<h1>Default content here</h1>

<div>
    @include($markdownViewName)
</div>

views/pages/release-notes.md:

## My markdown content

The code above generates a page like this for http://localhost/pages/release-notes:

<h1>Default content here</h1>

<div>
    <h2>My markdown content</h2>
</div>

from laravel-markdown.

GrahamCampbell avatar GrahamCampbell commented on July 17, 2024

We don't do this because blade syntax itself could be recognised by mistake as markdown, and thus, the file broken.

from laravel-markdown.

unnawut avatar unnawut commented on July 17, 2024

Right, I see. I'll see if I could make a blade syntax e.g. @markdown @endmarkdown instead.

from laravel-markdown.

GrahamCampbell avatar GrahamCampbell commented on July 17, 2024

That would work for sure. Would be pretty easy to implement.

from laravel-markdown.

GrahamCampbell avatar GrahamCampbell commented on July 17, 2024

Hmm, well, actually, not quite. Only if there was no other blade in between those annotations.

from laravel-markdown.

Related Issues (20)

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.