Code Monkey home page Code Monkey logo

textformatterfunkyfunctions's Introduction

TextformatterFunkyFunctions

Textformatter which is inspired by the TextformatterHannaCode module.

Allows you to add tags (“Funky Functions”) to your text fields which will be replaced by markup. The markup will be generated from script files either from a configurable path below site/ or from the site/templates/fields/ folder. In contrast to TextformatterHannaCode it does not come with a backend code editor interface. All scripts must be available as files in the mentioned paths.

Other characteristic are:

  • That it allows to directly pull data from fields on the same page
  • It allows to select items from array-like data by given ranges and/or indexes: images=1,3,6-9,12
  • It allows to select items from WireData derived data by given selector: images="description*=nice"
  • It allows to pull data from another page field into a tag attribute: [[nice-script field="selector"]]
  • It will render available scripts in templates/fields/ automatically as fallback and provide the value as $value
  • It will search for scripts in this order similar to $page->render()
    1. $givenPath/$funkyName/$pageTemplateName.php
    2. $givenPath/$funkyName.$pageTemplateName.php
    3. $givenPath/$pageTemplateName/$funkyName.php
    4. $givenPath/$funkyName.php
  • It is hookable to override rendering with own engine stuff

It is not (yet?) in the modules directory. Thus, I don't provide any support, but you can report bugs and errors anyway. That would be nice :)

Examples

[[nice-gallery images=1,2,3,6- type=special-kind]]

This will render the script nice-gallery.php with the variables $images and $type.
Value of $type will be "special-kind", value of $images will be items 1, 2, 3 and all the rest from item 6 up to the end of the images field of that name of the page. A variable $arguments is also provided with all “arguments”/variables bundled.

[[hero-image pictures="description*=nice"]]

This will render the script hero-image.php from the detected scripts folder and pull the image its description contains "nice".

[[images="description*=nice"]]

This will render the script images.php from the detected scripts folder and pull all images which have the "nice" in their description from images field.

Installation

The Processwire way.

Then, add this Textformatter in the details tab of the desired Textfield.

Changelog

1.2.0 - 2017/11/13, fixes

added: Also matches field references inside unquoted attribute values.
fix: Fetch correct values if attribute name and attriute values field reference are the same (Always fetch value field reference).

1.1.0 - 2017/11/3, added render function

added: A render function.

1.0.1 - 2017/10/31, fixed bug in regex

fixed: Greedy bug in regex.

1.0 - 2017/10/30, refactoring, added ability to filter by processwie selectors, pull data from

added: Ability to filter field values by processwire selectors
added: Ability to pull data from page fields into attributes
other: Refactoring

0.x - 2017/10/23, Initial release

textformatterfunkyfunctions's People

Contributors

blynx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

textformatterfunkyfunctions's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.