1

I am trying to preview input of form to another div as html markdown.

<div class="form-group" id="form">
  {!! Form::open(['route' => 'post.create']) !!}
    {{ Form::text('title', 'title', ['class' => 'form-control']) }}
    {{ Form::hidden('category_id', $category->id) }}
    {{ Form::textarea('body', 'body', ['class' => 'form-control', 'v-model' => 'input']) }}
    <div><?php echo '{{{ output }}}'; ?></div>
    {{ Form::submit('send', ['class' => 'btn btn-sm btn-default btn-block']) }}
  {!! Form::close() !!}
</div>

On app.js:

const app = new Vue({
    el: '#form',
    data: {
      input: '',
      output: ''
    },
    watch: {
      input: function(val) {
        this.output = marked(val);
      }
    }
});

@{{{ output }}}} returns the same result which is blank page with error on console:

- invalid expression: Unexpected token ) in

_s({ output)+"}"

Raw expression: {{{ output }}}
2
  • Why are you doing php echo at blade???? Commented Nov 7, 2017 at 23:34
  • it's basicly same as doing @{{{ output }}} as everyone else suggests Commented Nov 7, 2017 at 23:36

2 Answers 2

3

If your output is raw html use:

<div v-html="output"></div>
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah that's the one! Thanks!
0
<div v-text="output"></div>

or

<div>@{{ output }}</div>

or using old way in watch ...

input: function(val) {
    this.output = marked(val);
    $('div.output').text(this.output);
}

1 Comment

mersi azizam, but this returns with html tags as string

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.