5

I have a question about markItUp!'s preview function.

Inside jquery.markitup.js i have these settings:

previewTemplatePath:'~/templates/preview.php',
previewParserPath:'~/templates/preview.php',
previewParserVar:'data'

I'm not sure what to do with previewParserPath and previewParserVar. Is it possible to grab the content sent by markItUp in preview.php with PHP?

// preview.php
<body>
<!-- content -->
</body>
Farray
  • 8,290
  • 3
  • 33
  • 37
horgen
  • 2,183
  • 10
  • 30
  • 34

1 Answers1

7

You only need to set the previewParserPath and optionally the previewParserVar.

If you use this:

previewParserPath: '~/preview.php'

then markitup will look for a preview.php script to run in the same directory as the markitup jquery script--that's what the ~ character means.

If instead you set the preview path to something like this:

previewParserPath: '/preview.php'

then it will be relative to your web server root directory, as usual.

The implementation of the script it up to you; this is perhaps the most basic example:

echo htmlentities($_POST['data']);

The "data" there corresponds to the value of the previewParserVar setting; the default is "data".

In your app, you're probably going to want to do something useful with $_POST['data'] before you display it.

Wez Furlong
  • 4,727
  • 1
  • 29
  • 34