Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: User-defined plugins #779

Open
epage opened this issue Jul 7, 2020 · 5 comments
Open

RFC: User-defined plugins #779

epage opened this issue Jul 7, 2020 · 5 comments

Comments

@epage
Copy link
Member

epage commented Jul 7, 2020

We'd have a new folder _plugins full of FILLER that we load.

Plugins include

  • Liquid tags, blocks, and filters
    • For tags and blocks, we just parse all parameters as named or position arguments without any validating logic (ie Vec<(Option<KString>, Value)>) until end of %}. We then pass that to the plugin to deal with
    • Plugins can just accept these as arguments
    • Plugins can turn these into a form of syntax like treating one of the elements as a keyword

Open questions

  • What language?
    • Lua is well know
    • Rhai would integrate well with Rust
    • Dyon and Gluon are from the game community
  • Plugin per file or multiple in a file?
    • If multiple, whats the idiomatic way to do it for the given language?
@Geobert
Copy link
Contributor

Geobert commented Jul 7, 2020

Can you develop what kind of plugins?

On the language, I'd vote for Rhai, because Rust. And I have bad past experience with Lua (I don't know if it's still true, but the "if not marked as local, it's global) made me freak out a lot

@epage
Copy link
Member Author

epage commented Jul 7, 2020

Can you develop what kind of plugins?

So far the only ones I've thought are are listed:

Liquid tags, blocks, and filters

So say you want a custom shortcode plugin ({% youtube id="foobar" %}). In python (since I don't know the embedded languages) it'd look like

def plugins():
    return {
        "tag": {
            "youtube": youtube_shortcode,
        }
    }

def youtube_shortcode(arguments):
    args = {}
    for name, value in arguments:
        if name is None:
            raise ValueError("Only named arguments are supported")
        elif name in ["id"]:
            args[name] = value
        else:
            raise ValueError("Unsupported argument: %s" % name)
    ... do formatting ...
    return full_url

@Geobert
Copy link
Contributor

Geobert commented Jul 8, 2020

I see :) (Even if for shortcodes, I have something in antimoine to load custom shortcode, so they're easier to write, but maybe plugins is a better way?)

@epage
Copy link
Member Author

epage commented Jul 8, 2020

I see :) (Even if for shortcodes, I have something in antimoine to load custom shortcode, so they're easier to write, but maybe plugins is a better way?)

Shortcodes was a trivial example that can be solved in multiple ways. Other extensibilty ideas include filter-blocks and macros

cobalt-org/liquid-rust#321
cobalt-org/liquid-rust#322

@captn3m0
Copy link

captn3m0 commented May 8, 2023

If plugins are supported, having the ability to write custom generators in Rust would be nice.

I'd love to port https://github.com/avillafiorita/jekyll-datapage_gen/ and https://github.com/captn3m0/jekyll-sqlite/ for eg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants