Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/florianrappl/simplet
A simple C# class generator for static text templates.
https://github.com/florianrappl/simplet
c-sharp code-generation generator placeholder template-engine
Last synced: 10 days ago
JSON representation
A simple C# class generator for static text templates.
- Host: GitHub
- URL: https://github.com/florianrappl/simplet
- Owner: FlorianRappl
- License: mit
- Created: 2019-04-16T08:57:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T04:25:50.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T21:33:41.355Z (6 months ago)
- Topics: c-sharp, code-generation, generator, placeholder, template-engine
- Language: C#
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Simplet - .NET Template Bundler
[![Build Status](https://florianrappl.visualstudio.com/Simplet/_apis/build/status/Simplet-CI?branchName=master)](https://florianrappl.visualstudio.com/Simplet/_build/latest?definitionId=10&branchName=master)
[![GitHub Tag](https://img.shields.io/github/tag/FlorianRappl/Simplet.svg?style=flat-square)](https://github.com/FlorianRappl/Simplet/releases)
[![NuGet Count](https://img.shields.io/nuget/dt/Simplet.svg?style=flat-square)](https://www.nuget.org/packages/Simplet/)
[![Issues Open](https://img.shields.io/github/issues/FlorianRappl/Simplet.svg?style=flat-square)](https://github.com/FlorianRappl/Simplet/issues)A simple templating engine to generate valid C# classes from static text files. Convert your text files into code that can be checked at compile-time.
## Installation
Install the library via `dotnet` on the CLI:
```sh
dotnet tool install --global simplet
```## Usage
You'll need to have a config file. Let's name our config file `sample.json`. The following content is sufficient:
```json
{
"target": "dist",
"sources": [
{
"includes": [
"templates/*.html"
]
}
]
}
```This creates a new project in the directory `dist`. All HTML files from the `templates` directory will be converted to C# classes. As a follow up we may run
```sh
dotnet build dist
```To create a DLL containing the generated classes.
A full configuration file could look as follows:
```json
"name": "BigCo.Templates.Sample",
"target": "dist",
"framework": "netstandard1.3",
"description": "My project description",
"author": "BigCo",
"version": "1.2.3",
"sources": [
{
"placeholder": "%([A-Za-z]{1,32})%",
"name": "MyTemplate",
"includes": [
"templates/**/*.html"
],
"excludes": [
"templates/foo",
"templates/bar"
],
"parameter": "file",
"namespace": "BigCo.Templates.Sample.Html",
"sections": [
{
"format": "(.*)",
"title": "Content"
}
]
}
]
```The `parameter` accepts values such as `none` (default), `file`, `directory`, and `extension`. It pretty much determines if some internal grouping should be done before writing out files. A grouping of `file` would group in such a way that files in the same directory are collected and the name of the file needs to be used as a parameter.
## License
MIT License (MIT). For more information see [LICENSE](./LICENSE) file.