mood 0.2.2

PHP-like webpages with vibe.d.


To use this package, run the following command in your project's root directory:

mood

What is mood

mood builds on top of the core functionality of vibe.d. Instead of being a new framework, mood replaces the use of diet in favor of a more php-like system.

Getting Started

  1. Get from dub
  2. Create an html file and place whatever code you want into it.
<!DOCTYPE html>
<html>
    <body>
        <?D
            output("hello from mood");
        /?>
    </body>
</html>
  1. Render the page using moodRender.
router.get("/", moodRender!"index.html");

Using mood

You can open and close D-code tags like this:

<?D
    ...
/?>

Within each html file, one HTTPServerRequest req and one HTTPServerResponse res are pastitlesed as parameters, and available for use. Each html file also has the function output(T...)(T args), which writes data to the html document, as echo would in PHP. You can use this like you would writeln in the standard library.

Includes

The syntax for includes is very simple: <include:file.html/> Includes in mood insert the contents of the include file into the parent file. This includes all of its code, and its own includes.

Templates

To use templates, import mood.templates in your html file, and run the function that corresponds to the tag. You can use a template like:

output("Hello World".h1); // <h1>Hello World</h1>
output("Hello World".h1(`class="title"`)); // <h1 class="title">Hello World</h1>
output("Hello World".h1([
    `class`: `"title"`
])); // <h1 class="title">Hello World</h1>

Note: template, main, and object tags are not supported.

Parameters

Parameters (aka aliases) are supported just like they are in diet.

Inserts

Single statements that are non-void can be output to the webpage using {{ statement }} like most frontend frameworks.

Future Plans

  • More in-depth compilation error reporting. (Hopefully by-line+char error reporting).
  • Control flow tags. (for loops, if statements). Ex: vue.js v-for, v-if.

Contributing

If you have a suggestion, bug fix, or want a feature added, submit a PR, or an issue. Feedback is appreciated :)

Authors:
  • Reece Jones
Dependencies:
vibe-d:http
Versions:
0.2.2 2019-Sep-06
0.2.1 2019-Jun-08
0.2.0 2019-May-11
0.1.2 2019-Apr-23
0.1.1 2019-Apr-17
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 16 downloads total

Score:
0.4
Short URL:
mood.dub.pm