0

I try to make some documentation page, with several pages.

(I'm using Laragon and virtual host, so URLs are like mysite.dev/something)

I created 2 routes :

Route::get('docs','DocsController@index');
Route::get('docs/{text}','DocsController@index');

So when I write URL mysite.dev/docs, I get kinda like a docs home page.

Here's the controller :

class DocsController extends Controller
{
    public function index($text = '', $f = '') {
        if ($text != '')
            if (Storage::has('testText/'.$text.'.html'))
                $f = Storage::get('testText/'.$text.'.html');
            else
                $f = 'File doesn\'t exist...';

        return view('docs')->with('text',$f);
    }
}

I tested it on some text files, and it work pretty good with Storage, but in this code, you can see '.html' because i tried to do the same thing with html files. The result is the page containing the html code but written as text.

Is there a way to get this code from html files, and make it work as html ? Maybe there is a better Facade than Storage to do this, but I don't know very well Laravel.

3
  • 4
    Your docs blade template probably needs {!! $text !!} where you have {{ $text }}. Many assumptions on this so could be wrong so not posted as an answer Commented Apr 5, 2017 at 9:30
  • I had {{ $text }} and I think this the safe way to make some input etc, but {!! $text !!} actually take anything that it's given and display it correctly without doing anything. That's actually work perfectly for my case, Thx :) Commented Apr 5, 2017 at 9:42
  • Yeah - that's what it does. Upgraded to an answer :) Commented Apr 5, 2017 at 9:46

1 Answer 1

1

Your docs blade template probably needs {!! $text !!} where you have {{ $text }}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.