Skip to content

Use template comment syntax for header & footer placeholders #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/html/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ const _requiredTemplates = <String>[
'typedef.html',
];

const String _headerPlaceholder = '<!-- header placeholder -->';
const String _footerPlaceholder = '<!-- footer placeholder -->';
const String _footerTextPlaceholder = '<!-- footer-text placeholder -->';
const String _headerPlaceholder = '{{! header placeholder }}';
Copy link
Contributor

@jcollins-g jcollins-g Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a TODO for replacePlaceholder to port these to mustache rather than using our own template substitutions. A typo in the template would be less easy to miss that way.

const String _footerPlaceholder = '{{! footer placeholder }}';
const String _footerTextPlaceholder = '{{! footer-text placeholder }}';

Future<Map<String, String>> _loadPartials(
_TemplatesLoader templatesLoader,
Expand Down
5 changes: 3 additions & 2 deletions lib/templates/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{/packageGraph.hasFooterVersion}}
</span>

<!-- footer-text placeholder -->
{{! footer-text placeholder }}
</footer>

{{! TODO(jdkoren): unwrap ^useBaseHref sections when the option is removed.}}
Expand All @@ -17,7 +17,8 @@
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/highlight.pack.js"></script>
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/URI.js"></script>
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/script.js"></script>
<!-- footer placeholder -->

{{! footer placeholder }}

</body>

Expand Down
3 changes: 2 additions & 1 deletion lib/templates/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<link rel="stylesheet" href="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/github.css">
<link rel="stylesheet" href="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/styles.css">
<link rel="icon" href="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/favicon.png">
<!-- header placeholder -->

{{! header placeholder }}
</head>

{{! We don't use <base href>, but we do lookup the htmlBase from javascript. }}
Expand Down
4 changes: 2 additions & 2 deletions testing/test_package_custom_templates/templates/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{{packageGraph.defaultPackage.name}} {{packageGraph.defaultPackage.version}}
</p>

<!-- footer-text placeholder -->
{{! footer-text placeholder }}
</footer>

<!-- footer placeholder -->
{{! footer placeholder }}
</body>
</html>
2 changes: 1 addition & 1 deletion testing/test_package_custom_templates/templates/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>{{ title }}</title>
<!-- header placeholder -->
{{! header placeholder }}
</head>

<body>
Expand Down