angel_markdown 2.0.0

markdown #


Markdown view generator for Angel.

With this plug-in, you can easily serve static sites without doing more than writing simple Markdown. Thus, it is a friendly choice for writing API documentation or other tedious HTML-writing tasks.

Installation #

In your pubspec.yaml:

  angel_framework: ^1.0.0
  angel_markdown: ^1.0.0

Usage #

It's very straightforward to configure an Angel server to use Markdown. Keep in mind to use package:file instead of dart:io:

configureServer(Angel app) async {
  var fs = LocalFileSystem();
  await app.configure(markdown(
    // The directory where your views are located.'views'),

You can then generate HTML on-the-fly in a request handler. Assuming your view directory contained a file named, the following would render it as an HTML response:

configureServer(Angel app) async {
  app.get('/hello', (res) => res.render('hello'));

package:angel_markdown by default searches for files with a .md extension; however, you can easily override this.

Interpolation #

angel_markdown can interpolate the values of data from locals before building the Markdown.

For example, with the following template

# Species: {{}}
The species *{{}} {{}}* is fascinating...

You can render as follows:

requestHandler(ResponseContext res) {
  return res.render('species', {
    'species': new Species('sapiens', genius: 'homo')

To disable interpolation for a single bracket, prefix it with an @, ex: @{{raw | not_interpolated | angular}}.

Templates #

Markdown is frequently used to build the content of sites, but not the templates. You might want to wrap the content of pages in a custom template to apply pretty CSS and JS, etc:

configureServer(Angel app) async {
  await app.configure(
        // The directory where your views are located.'views'), template: (content, Map locals) {
      return '''<!DOCTYPE html>
        <title>${locals['title']} - My Site</title>

The template function will have access to whatever values were passed to the renderer, or an empty Map.

Enhancing Markdown #

You can pass an extensionSet to add additional features to the Markdown renderer. By default, this plug-in configures it to enable Github-flavored Markdown.

2.0.0 #

  • Angel 2 + Dart 2 updates.
  • Use package:file.


import 'dart:async';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_markdown/angel_markdown.dart';
import 'package:file/local.dart';

main() async {
  var app = await createServer();
  var http = AngelHttp(app);
  var server = await http.startServer(InternetAddress.loopbackIPv4, 3000);
  print('Listening at http://${server.address.address}:${server.port}');

Future<Angel> createServer() async {
  // Create a new server, and install the Markdown renderer.
  var app = new Angel();
  var fs = LocalFileSystem();
  await app
      .configure(markdown('views'), template: (content, locals) {
    return '''
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>${locals['title'] ?? 'Example Site'} - Example Site</title>
    <link rel="stylesheet" href="">
    <div class="ui top fixed menu">
      <a class="header item" href="/">
        <i class="home icon"></i>
    <div class="ui container" style="margin-top: 5em;">

  // Compile a landing page
  app.get('/', (req, res) => res.render('hello', {'title': 'Welcome'}));

  return app;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  angel_markdown: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:angel_markdown/angel_markdown.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/angel_markdown.dart. (-1.99 points)

Analysis of lib/angel_markdown.dart reported 4 hints:

line 7 col 24: Unnecessary new keyword.

line 44 col 13: DO use curly braces for all flow control structures.

line 44 col 19: Unnecessary new keyword.

line 64 col 30: Unnecessary new keyword.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
angel_framework ^2.0.0-alpha 2.1.1
file ^5.0.0 5.1.0
markdown ^2.0.0 2.1.3
Transitive dependencies
angel_container 1.1.0
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.1.0+1
args 1.5.2
charcode 1.1.3
code_buffer 1.0.1
collection 1.14.12
combinator 1.1.0
convert 2.1.1
crypto 2.1.4
dart2_constant 1.0.2+dart2
http2 1.0.0
http_parser 3.1.3
http_server 0.9.8+3
intl 0.16.1
logging 0.11.4
matcher 0.12.6
merge_map 1.0.2
meta 1.1.8
mime 0.9.6+3
mock_request 1.0.6
path 1.6.4
quiver 2.1.2+1
quiver_hashcode 2.0.0
recase 2.0.1 3.0.0
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.4
Dev dependencies
angel_test ^2.0.0
pedantic ^1.0.0
test ^1.0.0