Permalink
Browse files

doc: Strong-Mode support

  • Loading branch information...
MikeMitterer committed Nov 16, 2016
1 parent 1f3a2bb commit 8604ad8fa63721dabf58a11102278dee73df6082
View
@@ -0,0 +1,15 @@
# ------------------------------------------------------------------------------
# Config for Analyzer
# More: https://pub.dartlang.org/packages/analyzer
#
# Analyzer options:
# https://www.dartlang.org/guides/language/analysis-options
#
analyzer:
strong-mode: true
# Exclude wegen https://github.com/dart-lang/sdk/issues/26420
# und https://github.com/dart-lang/test/issues/436
# exclude:
# - test/**
View
@@ -3,7 +3,6 @@ library sitegen;
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'dart:isolate';
import 'dart:math';
import 'package:intl/intl.dart';
View
@@ -59,7 +59,7 @@ class Config {
_settings[Config._CONF_SASS_PATH] = "";
_settings[Config._CONF_BROWSER] = "Chromium";
_settings[Config._CONF_SITE_OPTIONS] = {};
_settings[Config._CONF_SITE_OPTIONS] = <String,String>{};
_settings[Options._ARG_IP] = "127.0.0.1";
_settings[Config._CONF_PORT] = "8080";
@@ -112,7 +112,7 @@ class Config {
String get sasspath => _sasspath;
Map<String,String> get siteoptions => _settings[Config._CONF_SITE_OPTIONS];
Map<String,String> get siteoptions => _settings[Config._CONF_SITE_OPTIONS] as Map<String,String>;
String get ip => _settings[Options._ARG_IP];
View
@@ -57,13 +57,13 @@ class Generator {
_logger.fine("\nFile: ${relativeFileName}, Path: $relativePath");
final List<String> lines = file.readAsLinesSync();
Map<String,dynamic> pageOptions = {};
Map<String,dynamic> pageOptions = <String,dynamic>{};
final bool hasYamlBlock = _hasYamlBlock(config.yamldelimeter,lines,extension);
if (hasYamlBlock) {
List<String> yamlBlock = _extractYamlBlockFrom(config.yamldelimeter,lines,extension);
if(yamlBlock.length > 0) {
pageOptions.addAll(yaml.loadYaml(yamlBlock.join('\n')));
pageOptions.addAll(yaml.loadYaml(yamlBlock.join('\n')) as Map<String,String>);
_resolvePartialsInYamlBlock(partialsDir,pageOptions,config.usemarkdown);
// +1 for the YAML-Block-Delimiter ("~~~") line
@@ -77,7 +77,8 @@ class Generator {
pageOptions = _fillInDefaultPageOptions(config.dateformat,file, pageOptions,config.siteoptions);
pageOptions['_data'] = dataMap;
pageOptions['_content'] = renderTemplate(lines.join('\n'), pageOptions,
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown));
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)
);
pageOptions['_template'] = "none";
@@ -101,7 +102,8 @@ class Generator {
}
final String content = _fixPathRefs(renderTemplate(templateContent, pageOptions,
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)),config);
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)
),config);
final String outputFilename = "${path.basenameWithoutExtension(relativeFileName)}.${outputExtension}";
final Directory outputPath = _createOutputPath(outputDir,relativePath);
@@ -166,7 +168,7 @@ class Generator {
* Example:
* Name: category.house -> category/house.[html | md]
*/
Function _partialsResolver(final Directory partialsDir,{ final bool isMarkdownSupported: true}) {
PartialsResolver _partialsResolver(final Directory partialsDir,{ final bool isMarkdownSupported: true}) {
Validate.notNull(partialsDir);
mustache.Template resolver(final String name) {
@@ -319,7 +321,7 @@ class Generator {
return startsWithString;
}
Map _fillInDefaultPageOptions(final String defaultDateFormat,final File file, Map pageOptions,final Map<String,String> siteOptions) {
Map<String,dynamic> _fillInDefaultPageOptions(final String defaultDateFormat,final File file,final Map<String,dynamic> pageOptions,final Map<String,String> siteOptions) {
final String filename = path.basenameWithoutExtension(file.path);
pageOptions.putIfAbsent('title', () => filename);
@@ -482,7 +484,7 @@ class Generator {
_logger.fine(" ${"".padRight(nestingLevel * 2)} $key.");
if(value is Map) {
_showMap(value,nestingLevel + 1);
_showMap(value as Map<String,dynamic>,nestingLevel + 1);
} else {
String valueAsString = value.toString().replaceAll(new RegExp("(\n|\r|\\s{2,}|${_NEWLINE_PROTECTOR})",multiLine: true),"");
@@ -14,7 +14,7 @@ default_vars:
- "`_content`: post content (only accessible from templates, not markdown)"
# Alternate List Syntax
authors: [foo, bar, baz]
authors: [hallo,foo,bar,baz]
# A list of Dictionaries
links:
@@ -68,17 +68,19 @@ Some vars that are always available by default:
Image: ![Logo](assets/images/ios-desktop.png)
{{#each items}}
----
{{#_data.items}}
<li>
{{name}}
{{#if items}}
<ul>
{{> list}}
</ul>
{{/if}}
{{/if items}}
</li>
{{/each}}
{{/_data.items}}
----
{{#default_vars}}
{{.}}
@@ -1,3 +1,5 @@
import 'dart:html' as html;
import 'package:logging/logging.dart';
import 'package:console_log_handler/console_log_handler.dart';
@@ -91,11 +91,24 @@ <h4>Subheadline</h4>
<p>And anything beyond that gets interpreted as <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a>!</p>
<p>You can even use template tags in here, for any variables you set in in the top YAML block, or in your <code>site.yaml</code> file:</p>
<p>This post's title is: "Markdown"</p>
<p>This file was last modified on 2/19/2016</p>
<p>This file was last modified on 11/16/2016</p>
<p>Link to <a href="about/">subpages</a></p>
<p>Note that variables beginning with an underscore designate <em>implicit</em> metadata added by <strong>SiteGen</strong>.</p>
<p>Some vars that are always available by default:</p>
<p>Image: <a href="assets/images/ios-desktop.png"><img alt="Logo" src="assets/images/ios-desktop.png"></img></a></p>
<hr /><li>
foo1
</li>
<li>
foo2
</li>
<li>
foo3
</li>
<li>
foo8
</li>
<hr />
<pre><code>`title`: post title, automatically set to name of markdown file if left blank
`_site`: site.yaml values
`_date`: post 'last modified' date
@@ -108,7 +121,7 @@ <h4>Subheadline</h4>
<a href="http://google.com">Google</a><br />
<a href="http://github.com">Github</a> </p><ul><li><a href="https://github.com/MikeMitterer/dart-sitegen">SiteGen</a></li><li><a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a></li><li><a href="http://mustache.github.io/mustache.5.html">Mustache</a></li><li>
<p><a href="http://rhnh.net/2011/01/31/yaml-tutorial">YAML</a></p></li><li>
<p>foo</p></li><li>bar</li><li>baz</li></ul>
<p>hallo</p></li><li>foo</li><li>bar</li><li>baz</li></ul>
<p>Note how you need to use a <code>.</code> to access a list item, but can access map/dict keys directly.</p>
<p>You can of course disable these markdown templating features by setting <code>markdown_templating: true</code> in your site.yaml file.
Same ideas apply when writing your actual HTML templates. See <a href="http://mustache.github.io/mustache.5.html">mustache's docs</a> for more templating info.</p>
View
@@ -1,6 +1,6 @@
import 'package:grinder/grinder.dart';
main(args) => grind(args);
main(final List<String> args) => grind(args);
@Task()
@Depends(test,buildSamples)

0 comments on commit 8604ad8

Please sign in to comment.