Releases: BritishWerewolf/blogs-md-easy
0.3.2 - Look! A Library!
This release adds a lib.rs
file to the package.
What this means, is that we can compile the binary and use
the package in other projects without needing to maintain two codebases.
New Filters
Additional filters have been added: reverse
and truncate
.
reverse
will simply reverse the value, truncate
is slightly more complicated.
This is the syntax for any placeholder within the templates.
{{ £variable_name[ | filter_name[ = [key: ]value]...] }}
All filters are completely optional, and can be chained by placing a |
after each call.
Some filters don't have any arguments, and any that do always have default values, as well as one of the arguments being deemed as the default argument.
As of this release, there is just a single filter that accepts arguments: truncate
.
truncate
has the following signature.
truncate = characters: 20, trail ...
Here the defaults are provided. It's important to note that characters
is the default argument.
**What's a default argument?
This is just a convenience to keep templates from becoming verbose.
Giving a filter a default argument (as well as default values!), means that we can just simply provide the filter name, and get sensible defaults.
Let's look at an example.
<p>{{ £content | truncate }}</p>
This is nice and simple, we are just using the default values here, but what about if we wanted to change the point at which we truncate?!
Well, now we have two options.
<p>{{ £content | truncate = 42 }}</p>
<p>{{ £content | truncate = characters: 42 }}</p>
By assuming that a value without a key, is a particular key, then we can keep our templates more concise.
If you wish to change any value that is not the default, then you will always need to provide that key. That means that this is invalid.
<p>{{ £content | truncate = -- }}</p>
This will attempt to assign --
to the characters
key, which will break as that expects an unsigned integer.
Justfile
There is now a justfile
which will start adding more recipes.
This should just help building the project and testing.
Housekeeping
Now that we have a lib.rs
and main.rs
file; the functionality has been split across these files.
Tests have been moved to a tests/tests.rs
file too.
This also has the benefit of giving us a docs.rs
page too!
Full Changelog: 0.2.1...0.3.2
0.2.0 - Filter Functions, Finally
This release adds the ability to mutate your placeholder variables, by providing a pre-defined filter function, following a pipe (|
).
It's as simple as this {{ £title | uppercase }}
!
Available filters are:
lowercase
- converts the entire string to lowercaseuppercase
- converts the entire string to uppercasemarkdown
- parses the string and converts to HTML
More filters will be added in future.
Full Changelog: 0.1.5...0.2.0
0.1.0 - First Stable Release (Alpha)
Blogs Made Easy
I wanted a way to convert my Markdown files into a premade template HTML file. A solution almost certainly exists, but I wanted to build something myself and practice my Rust skills.
Two things to note here:
- I like puns, and couldn't resist not naming it thusly.
- In keeping with my username, I used
£
in front of my variables instead of the usual$
(because I wanted to honour PHP).
This should be a stable release.
Run this in the Terminal, providing the --help
switch to see usage, or consult the README for example usage.
Now available on crates.io, and installable with:
$ cargo install blogs-md-easy
Features:
- Populate a template with placeholder variables such as
{{ £author }}
. - Convert Markdown into template, populating variables.
- Provide variables within Markdown to add additional meta data to template.
Full Changelog: 0.0.1...0.1.0