GithubHelp home page GithubHelp logo

rocher / mold_lib Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 449 KB

Meta-variable Operations for Lean Development

Home Page: https://rocher.github.io/mold

License: MIT License

Ada 98.98% Shell 0.45% Awk 0.57%
ada ada-library template template-engine template-project alire-crate

mold_lib's Introduction

Alire Alire CI/CD unit-test codecov GitHub release License

Welcome to Mold

MOLD: Meta-variable Operations for Lean Development

Mold is a Template Processor, or Template Engine, to work with repository templates. The main motivation of Mold is to have repositories in GitHub used as template repositories to create new, customized repositories for other users.

Main features supported in Mold include

  • variable replacement in mold files (*.mold)

  • for a given directory, variable replacement recursively for all mold files in all subdirectories

  • variable replacement in file names

  • inclusion of other templates

  • definition of variables with a simple TOML file

  • predefined and customized text filters to easily apply text transformations

Variable replacement can be specified as normal, optional or mandatory. For example, the variable foo = "bar" can be specified with {{foo}}, {{?foo}} (optional) or {{#foo}} (mandatory). The difference is the handling of errors when an undefined variable is encountered.

All mold files must end with the extension .mold, for example README.md.mold. Destination files (with variables replaced) have the same name without the mold extension: README.md. This simplifies the work done in large subdirectories with few templates.

Text filters can be used to apply text transformations, for example {{foo/W5}} truncates the contents of the variable foo to a maximum width of 5 characters.

This crate contains the Ada library and unit tests. For a CLI tool, please take a look at the crate mold.

Reference Guide

Please visit Mold documentation for more information.


License

MIT (c) 2023, 2024 Francesc Rocher

mold_lib's People

Contributors

rocher avatar

Stargazers

 avatar

Watchers

 avatar  avatar

mold_lib's Issues

[Feature request] Supporting substitutions in string parameters

Hi @rocher,

Very interesting project.

After a quick look, I think the library doesn't support substituting inside a passed string. I have a project idea in which the program will programmatically determine the values to make the substitution in a template. The template could be passed to the program by the user, but I'd like also to have a default template valid for most use cases. If the default template could be stored in memory as a string, there wouldn't be any need to add it to the program as a resource (either external or embedded with some library). The program determines the values, it calls mold_lib to do the substitutions passing the default in memory template, and the resulting string is dumped to the final file by the program.

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.