angel_markdown 1.0.0+1

  • README.md
  • Installing
  • Versions
  • 46

markdown

Pub

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:

dependencies:
  angel_framework: ^1.0.0
  angel_markdown: ^1.0.0

Usage

It's very straightforward to configure an Angel server to use Markdown:

configureServer(Angel app) async {
  await app.configure(markdown(
    // The directory where your views are located.
    new Directory('views'),
  ));
}

You can then generate HTML on-the-fly in a request handler. Assuming your view directory contained a file named hello.md, 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.md:

# Species: {{species.name}}
The species *{{species.genus.name}} {{species.name}}* 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(
    markdown(
        // The directory where your views are located.
        new Directory('views'), template: (content, Map locals) {
      return '''<!DOCTYPE html>
<html>
    <head>
        <title>${locals['title']} - My Site</title>
    </head>
    <body>
      $content
    </body>
</html>
        ''';
    }),
  );
}

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.

1. Depend on it

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


dependencies:
  angel_markdown: "^1.0.0+1"

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';
        
Version Uploaded Documentation Archive
1.0.0+1 Aug 13, 2017 Go to the documentation of angel_markdown 1.0.0+1 Download angel_markdown 1.0.0+1 archive
1.0.0 Aug 13, 2017 Go to the documentation of angel_markdown 1.0.0 Download angel_markdown 1.0.0 archive

Analysis

This feature is new.
We welcome feedback.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Dec 6, 2017
  • Dart: 2.0.0-dev.8.0
  • pana: 0.7.3+1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
79
Overall score:
Weighted score of the above. [more]
46

Platforms

Detected platforms: server

All libraries agree

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

Dependencies

Package Constraint Resolved Available
Direct dependencies
angel_framework ^1.0.0 1.1.0
markdown ^0.11.4 0.11.4 1.0.0
Transitive dependencies
angel_http_exception 1.0.0
angel_model 1.0.0
angel_route 2.0.5
async 2.0.1
body_parser 1.0.3
charcode 1.1.1
collection 1.14.3
combinator 1.0.0-beta+7
container 0.1.2
http_server 0.9.6
json_god 2.0.0-beta+1
logging 0.11.3+1
matcher 0.12.1+4
merge_map 1.0.0
meta 1.1.2
mime 0.9.4
path 1.5.1
pool 1.3.3
quiver_hashcode 1.0.0
random_string 0.0.1
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
tuple 1.0.1
Dev dependencies
angel_test ^1.0.0
test ^0.12.0