View Source Conpipe

A Converter Pipeline with a composable library of operations. Conpipe wraps template processors (eg EEx, Liquid) and plain-text markup languages (eg Markdown, Asciidoc). Conpipe is:

  • intended for use in Static Site Generators like Tableau
  • designed to be extended

Installation

Add conpipe to your list of dependencies in mix.exs:

def deps do
  [
    {:conpipe, "~> 0.1.0"}
  ]
end

Online docs are at https://hexdocs.pm/conpipe.

Converters

A converter is a module with a convert/2 function that implements the Conpipe.Converter behavior. Here's a converter that processes Liquid tags:

defmodule MyLiquidConverter do
  @behavior Conpipe.Converter 

  def convert({text, assigns}, opts \\ []) do
    {:ok, template} = Solid.parse(text, opts)
    output = Solid.render!(template, assigns) |> to_string
    {output, assigns}
  end
end

Converters can be chained in Elixir pipes:

defmodule My.DoItAllConverter do 
  @behavior Conpipe.Converter 

  def convert({text, assigns}, _opts \\ []) do 
    {text, assigns} 
    |> Conpipe.Converter.Solid.convert()
    |> MyConverter.convert()
    |> Conpipe.Converter.Mdex.convert()
    |> MyHtmlPostProcessor.convert()
  end
end

Converters can be composed and run in a pipeline:

[Conpipe.Converter.Solid, MyConverter, Conpipe.Converter.Mdex] 
|> Conpipe.Runner.reduce(text, assigns)

This project ships with a library of converters that can be reused across applications:

Markup Languages

Template Processors

Find an up-to-date list of converters in the online documentation.

Tableau Integration

Adding use Conpipe.Extended to a converter provides a convert/4 function that can be called directly from Tableau.

defmodule MyConverter do 
  @behavior Conpipe.Converter 
  use Conpipe.Extended 

  def convert({text, assigns}, _opts \\ []) do 
    {text, assigns} 
    |> Conpipe.Converter.Solid.convert()
    |> Conpipe.Converter.Mdex.convert()
  end
end

Then in config/config.exs

config :tableau, :config,
  url: "http://localhost:4999",
  converters: [
    md: MyConverter
  ]

All converters in this package use TableauAdapter.

Contributions

Pull Requests welcome! PR's require Conventional Commits, passing tests and formatted code.

Pre-commit hooks and setup scripts can be found in .github/hooks.