Version 0.1.1
Key Replacement Plugin is a Publii Plugin that replaces specific keys with designated text strings in the HTML output form Publii.
Note: This plugin DOES NOT replace or even enable much of the functionality of the commercially (at a very fair price) Smart Replacer plugin available from the folks who make Publii possible. I recommend their plugin for anything that involves more than a simple AAA -> BBB type replacement. Get it here: Smart Replacer Plugin
Download the plugin in zip file format: Key_Replacement.zip
Install the plugin as you would any other Publii Plugin. Instructions for installing plugins is located here.
- After installing the plugin go to "Tools & Plugins" in the Publii main menu and locate the plugin. Activate it by flipping the toggle switch as shown below.
- Click on the Plugin and create rules. Shown in the image below are three rules.
Rules can be simple replacement of one short string with another you might use all the time. Do you want to inject a <div>
with a class - you can do that also. Don't forget to close the <div>
- right.
Warning - DO NOT USE double quotation marks in the replacement text. The parser has trouble working with it.
- Use your new keys (they are like shortcodes in other CMS) in your posts and/or pages as shown in the image below.
- If you are injecting a class via a
<div>
or other element - add the class to your custom CSS (presuming that is the reason for the class). By the way - I recommend using classes and not injecting CSS directly into your page. It is easy, it is maintainable and it i reusable.
In this image you can see the class has been applied and the replaement text has been injects into the paragraph also.
Check out the page under the inspector. You can see the <div>
that was added.
No software is perfect. This was slapped together in a day. I would imaging there are use cases that it cannot handle and issues that will cause it to crash. It is probably a good idea to backup your data before rendering with this plugin.
Also - Remember that double quotations will crash the injector. It sounds like a car! :(
Use single quotes instead of double quotes. Double quotes will muck everything up.
If you need something contained in double quotes between the single quotation marks then use the HTML code "
!