Knap.md
LogicFiltersVariablesAPIGitHub ↗

Guide

VariablesLogicFilters

Reference

API

Project

GitHub ↗npm ↗

strip_attr

Remove every HTML attribute except an optional allowlist.

Filters/strip_attr

Syntax

{{ value | strip_attr }}{{ value | strip_attr:"href" }}

Example

01

Basic usage

InputTS
1{2  "html": "<a href=\"/about\" class=\"nav\">About</a>"3}
TemplateKNAP
1{{ html | strip_attr:"href" }}
OutputKNAP
1<a href="/about">About</a>

Related filters

remove_attrRemove selected attributes from HTML tags.
Previous← replace_tagsNextstrip_md →
Knap is open source under the MIT license.View source ↗

On this page

SyntaxExamplesRelated filters
strip_attr filter — Knap