Skip to content

Preview Revision

Muah edited this page Mar 20, 2018 · 5 revisions

Starting of v1.2.0, we will be able to preview the revision on the fly.

note that if you don't need this feature, no changes is required, just follow the default usage steps and you are done.


To make this as flexible as possible without enforcing any specific code flow

there are only a couple of extra steps that needs to be made to get this to work.

  • add a new template param to the include declaration.

    • the template path is relative to views, for example views/posts/preview.

    • the template name could be anything you want, this is just a place to send the revision data to.

      @if (count($post->revisions))
          @include('Odin::list', [
            'revisions' => $post->revisions, 
            'template' => 'posts.preview'
          ])
      @endif
  • the returned payload variable is $data, so inside the preview file call any property as usual like

    {{ $data->cover }}
    {{ $data->title }}
    {{ $data->body }}
    // etc...

Notes

  • don't try to edit the returned payload directly as it could lead to some side effects.
  • any operations to the revision should be done through the main view, that's why we automaticlly open the preview in a new tab so you can just switch the tab and continue from where you left.