Diamond is a full-stack web-framework written in The D Programming Language using vibe.d
Diamond is a powerful full-stack web-framework written in the D Programming Language.
Diamond can be used to write powerful websites, webapis or as stand-alone as a template parser.
Website: https://diamondmvc.org/
Package | Version | Description |
---|---|---|
vibe.d | 0.8.3 | Used as the backend for Diamond's web applications. From 3.0.0 vibe.d will be an optional dependency. |
DMD/Phobos | 2.072.2 - 2.077.0 | The standard library of D and thus a required dependency. |
Mysql-native | 2.2.1 | A native wrapper for Mysql. It's a dependency, because of the MySql ORM. |
ddbc | X.X.X | A database wrapper in D to a lot of database systems. Diamond will be using it for PostgreSQL, Sqlite and MSSQL. |
Layout:
@<doctype>
<html>
<head>
<title>Website - @<title></title>
</head>
<body>
@<view>
</body>
</html>
View:
@[
layout:
layout
---
route:
home
---
model:
Home
---
controller:
HomeController
---
placeholders:
[
"title": "Home"
]
]
<p>Hello @=model.name;!</p>
module controllers.homecontroller;
import diamond.controllers;
final class HomeController(TView) : Controller!TView
{
this(TView view)
{
super(view);
}
/// / || /home
@HttpDefault Status defaultAction()
{
view.model = new Home("World!");
return Status.success;
}
/// /home/setname/{name}
@HttpAction(HttpPost) Status setName()
{
auto name = this.getByIndex!string(0);
view.model = new Home(name);
return Status.success;
}
}
module models.home;
final class Home
{
private:
string _name;
public:
final:
this(string name)
{
_name = name;
}
@property
{
string name() { return _name; }
}
}
Layout:
@(doctype)
<html>
<head>
<title>Website - @(title)</title>
</head>
<body>
@(view)
</body>
</html>
View:
@[
layout:
layout
---
route:
home
---
model:
Home
---
controller:
HomeController
---
placeholders:
[
"title": "Home"
]
]
<p>Hello @=model.name;!</p>
module controllers.homecontroller;
import diamond.controllers;
final class HomeController(TView) : WebController!TView
{
this(TView view)
{
super(view);
}
/// / || /home
@HttpDefault Status defaultAction()
{
view.model = new Home("World!");
return Status.success;
}
/// /home/setname/{name}
@HttpAction(HttpPost) Status setName(string name)
{
view.model = new Home(name);
return Status.success;
}
}
module controllers.usercontroller;
import diamond.controllers;
final class UserController : ApiController
{
this(HttpClient client)
{
super(client);
}
/// /user/update
@HttpAction(HttpPost) Status update(UserModel user)
{
// Do stuff ...
return Status.success;
}
}
module models.home;
final class Home
{
private:
string _name;
public:
final:
this(string name)
{
_name = name;
}
@property
{
string name() { return _name; }
}
}
...
module models.user;
final class User
{
public:
string name;
int age;
}
See: https://diamondmvc.org/faq
See: https://diamondmvc.org/docs/views/#syntax
See: https://diamondmvc.org/download
Not supported since 3.0.0
See: https://diamondmvc.org/contribute
Diamond only supports up to the 3 latest minor versions of itself, including pre-release versions.
If a version is not supported its working branch is deleted.
Anything below 2.10.0 is no longer supported, because earlier versions are not adviced to use unless necessary.
2.10.0+ is generally backward compatible, but 3.0.0 is not.
Currently supported versions: 2.10.0 - 3.0.0
No longer supported (Only available in release.): < 2.10.0
Note: 3.0.0 is not yet supported, but the master branch is 3.0.0