1

I am using this DataTable plugin for Laravel, which is for using This jQuery DataTable plugin.

I Followed the instructions found here, so this is my controller:

class FeedbackController extends Controller {

    public function UserFeedback(Request $request) {
        $t = Datatable::make(new CollectionProvider(FeedbackModel::all()))
            ->column('overall')
            ->build();

        if ($t->shouldHandle()) {
            return $t->handleRequest();
        }

        return view('admin.feedback', ['datatable' => $t->view()]);
    }

}

And this is in my view:

{{
    $datatable->html()
}}

But for some reason when I load the page it is outputting the html with htmlentities like this:

<table id="dataTable">
    </table><script type="text/javascript">
    jQuery(document).ready(function () {
        // dynamic table
        oTable = jQuery('#dataTable').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "/",
            "columns": [
                                { 'data': 'overall' },
                            ]
        });
    });
</script>

Why is it doing this?

1 Answer 1

1

This will help you (taken from laravel docs)

Displaying Raw Text With Curly Braces

If you need to display a string that is wrapped in curly braces, you may escape the Blade behavior by prefixing your text with an @ symbol:

@{{ This will not be processed by Blade }}

If you don't want the data to be escaped, you may use the following syntax:

Hello, {!! $name !!}.

Use that on this...

{{
    $datatable->html()
}}

Ignore the above, that is the wrong way around, do the below...

Or

You can decode the html like this...

htmlspecialchars_decode($datatable->html())

and output that...

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.