Skip to content

<OctoberFilter />

Processes text using an OctoberCMS Markdown filter.

The <OctoberFilter /> component sends a string to an OctoberCMS Markdown filter and renders the returned HTML. It refreshes automatically when the selected filter or input value changes.

WARNING

Filtered content is inserted using innerHTML. Select the appropriate safe or cleaning filter whenever the source may contain untrusted content.

Basic Usage

vue
<template>
    <OctoberFilter name="md_safe" :value="article.content" />
</template>

<script lang="ts" setup>
import { OctoberFilter } from '@ratmd/laika';
</script>

The processed HTML is rendered inside a <div> by default.

Available Properties

PropertyTypeDefaultDescription
namemd, md_safe, md_clean or md_indentRequired OctoberCMS Markdown filter.
valuestring''Source content passed to the filter.
tagstringdivHTML element used to contain the processed output.
vue
<OctoberFilter
    name="md_safe"
    :value="article.content"
    tag="article"
/>

Custom Rendering

Use the default slot to control how loading, error and result states are displayed.

vue
<OctoberFilter name="md" :value="article.content">
    <template #default="{ value, pending, error, refresh }">
        <p v-if="pending">Rendering content...</p>
        <p v-else-if="error">{{ error.message }}</p>
        <div v-else v-html="value"></div>

        <button type="button" @click="refresh">
            Refresh
        </button>
    </template>
</OctoberFilter>

The default slot receives the following properties.

PropertyTypeDescription
valuestringHTML returned by the selected OctoberCMS filter.
pendingbooleanWhether the filter request is currently running.
errorError or nullError returned by the most recent request.
refresh() => Promise<void>Runs the filter again with the current properties.

Without a slot, the generated element receives data-loading="true" while the request is pending and a data-error attribute when the request fails.

This software is not an official OctoberCMS product and is not associated with, sponsored by, or endorsed by OctoberCMS.