Escape HTML the right way
This commit is contained in:
parent
f6272e110f
commit
358c213b87
@ -1,8 +1,8 @@
|
||||
@misc{<<PKG>>.jl,
|
||||
author = {<<AUTHORS>>},
|
||||
title = {<<PKG>>.jl},
|
||||
url = {<<URL>>},
|
||||
@misc{<<&PKG>>.jl,
|
||||
author = {<<&AUTHORS>>},
|
||||
title = {<<&PKG>>.jl},
|
||||
url = {<<&URL>>},
|
||||
version = {v0.1.0},
|
||||
year = {<<YEAR>>},
|
||||
month = {<<MONTH>>}
|
||||
year = {<<&YEAR>>},
|
||||
month = {<<&MONTH>>}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
# {{PKG}}{{#HAS_INLINE_BADGES}} {{#BADGES}}{{.}} {{/BADGES}}{{/HAS_INLINE_BADGES}}
|
||||
# {{{PKG}}}{{#HAS_INLINE_BADGES}} {{#BADGES}}{{{.}}} {{/BADGES}}{{/HAS_INLINE_BADGES}}
|
||||
{{^HAS_INLINE_BADGES}}
|
||||
|
||||
{{#BADGES}}
|
||||
{{.}}
|
||||
{{{.}}}
|
||||
{{/BADGES}}
|
||||
{{/HAS_INLINE_BADGES}}
|
||||
{{#HAS_CITATION}}
|
||||
|
@ -2,17 +2,17 @@
|
||||
environment:
|
||||
matrix:
|
||||
{{#VERSIONS}}
|
||||
- julia_version: {{.}}
|
||||
- julia_version: {{{.}}}
|
||||
{{/VERSIONS}}
|
||||
platform:
|
||||
{{#PLATFORMS}}
|
||||
- {{.}}
|
||||
- {{{.}}}
|
||||
{{/PLATFORMS}}
|
||||
{{#HAS_ALLOW_FAILURES}}
|
||||
matrix:
|
||||
allow_failures:
|
||||
{{#ALLOW_FAILURES}}
|
||||
- julia_version: {{.}}
|
||||
- julia_version: {{{.}}}
|
||||
{{/ALLOW_FAILURES}}
|
||||
{{/HAS_ALLOW_FAILURES}}
|
||||
branches:
|
||||
|
@ -1,10 +1,10 @@
|
||||
freebsd_instance:
|
||||
image: {{IMAGE}}
|
||||
image: {{{IMAGE}}}
|
||||
task:
|
||||
name: FreeBSD
|
||||
env:
|
||||
{{#VERSIONS}}
|
||||
JULIA_VERSION: {{.}}
|
||||
JULIA_VERSION: {{{.}}}
|
||||
{{/VERSIONS}}
|
||||
install_script:
|
||||
- sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)"
|
||||
|
@ -18,16 +18,16 @@
|
||||
@printf "Test coverage %.2f%%\n" 100c / t;'
|
||||
{{/HAS_COVERAGE}}
|
||||
{{#VERSIONS}}
|
||||
Julia {{.}}:
|
||||
image: julia:{{.}}
|
||||
Julia {{{.}}}:
|
||||
image: julia:{{{.}}}
|
||||
<<: *script
|
||||
{{#HAS_COVERAGE}}
|
||||
{{#HAS_COVERAGE}}
|
||||
<<: *coverage
|
||||
{{/HAS_COVERAGE}}
|
||||
{{/HAS_COVERAGE}}
|
||||
{{/VERSIONS}}
|
||||
{{#HAS_DOCUMENTER}}
|
||||
pages:
|
||||
image: julia:{{VERSION}}
|
||||
image: julia:{{{VERSION}}}
|
||||
stage: deploy
|
||||
script:
|
||||
- julia --project=docs -e '
|
||||
|
@ -1,8 +1,8 @@
|
||||
# {{PKG}}
|
||||
# {{{PKG}}}
|
||||
|
||||
```@index
|
||||
```
|
||||
|
||||
```@autodocs
|
||||
Modules = [{{PKG}}]
|
||||
Modules = [{{{PKG}}}]
|
||||
```
|
||||
|
@ -1,18 +1,18 @@
|
||||
using {{PKG}}
|
||||
using {{{PKG}}}
|
||||
using Documenter
|
||||
|
||||
makedocs(;
|
||||
modules=[{{PKG}}],
|
||||
authors="{{AUTHORS}}",
|
||||
repo="https://{{REPO}}/blob/{commit}{path}#L{line}",
|
||||
sitename="{{PKG}}.jl",
|
||||
modules=[{{{PKG}}}],
|
||||
authors="{{{AUTHORS}}}",
|
||||
repo="https://{{{REPO}}}/blob/{commit}{path}#L{line}",
|
||||
sitename="{{{PKG}}}.jl",
|
||||
format=Documenter.HTML(;
|
||||
{{#CANONICAL}}
|
||||
canonical="{{CANONICAL}}",
|
||||
canonical="{{{CANONICAL}}}",
|
||||
{{/CANONICAL}}
|
||||
assets={{^HAS_ASSETS}}String{{/HAS_ASSETS}}[{{^HAS_ASSETS}}],{{/HAS_ASSETS}}
|
||||
{{#ASSETS}}
|
||||
"{{.}}",
|
||||
"{{{.}}}",
|
||||
{{/ASSETS}}
|
||||
{{#HAS_ASSETS}}
|
||||
],
|
||||
@ -22,12 +22,12 @@ makedocs(;
|
||||
"Home" => "index.md",
|
||||
],
|
||||
{{#MAKEDOCS_KWARGS}}
|
||||
{{first}}={{second}},
|
||||
{{{first}}}={{{second}}},
|
||||
{{/MAKEDOCS_KWARGS}}
|
||||
)
|
||||
{{#HAS_DEPLOY}}
|
||||
|
||||
deploydocs(;
|
||||
repo="{{REPO}}",
|
||||
repo="{{{REPO}}}",
|
||||
)
|
||||
{{/HAS_DEPLOY}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using {{PKG}}
|
||||
using {{{PKG}}}
|
||||
using Test
|
||||
|
||||
@testset "{{PKG}}.jl" begin
|
||||
@testset "{{{PKG}}}.jl" begin
|
||||
# Write your tests here.
|
||||
end
|
||||
|
@ -4,11 +4,11 @@ notifications:
|
||||
email: false
|
||||
julia:
|
||||
{{#VERSIONS}}
|
||||
- {{.}}
|
||||
- {{{.}}}
|
||||
{{/VERSIONS}}
|
||||
os:
|
||||
{{#OS}}
|
||||
- {{.}}
|
||||
- {{{.}}}
|
||||
{{/OS}}
|
||||
jobs:
|
||||
fast_finish: true
|
||||
@ -16,19 +16,19 @@ jobs:
|
||||
allow_failures:
|
||||
{{/HAS_ALLOW_FAILURES}}
|
||||
{{#ALLOW_FAILURES}}
|
||||
- julia: {{.}}
|
||||
- julia: {{{.}}}
|
||||
{{/ALLOW_FAILURES}}
|
||||
{{#HAS_JOBS}}
|
||||
include:
|
||||
{{/HAS_JOBS}}
|
||||
{{#X86}}
|
||||
- julia: {{JULIA}}
|
||||
os: {{OS}}
|
||||
- julia: {{{JULIA}}}
|
||||
os: {{{OS}}}
|
||||
arch: x86
|
||||
{{/X86}}
|
||||
{{#HAS_DOCUMENTER}}
|
||||
- stage: Documentation
|
||||
julia: {{VERSION}}
|
||||
julia: {{{VERSION}}}
|
||||
script: julia --project=docs -e '
|
||||
using Pkg;
|
||||
Pkg.develop(PackageSpec(; path=pwd()));
|
||||
|
@ -75,10 +75,10 @@ If that's the case, a basic understanding of [Mustache](https://mustache.github.
|
||||
Here's an example template file:
|
||||
|
||||
```
|
||||
Hello, {{name}}.
|
||||
Hello, {{{name}}}.
|
||||
|
||||
{{#weather}}
|
||||
It's {{weather}} outside.
|
||||
It's {{{weather}}} outside.
|
||||
{{/weather}}
|
||||
{{^weather}}
|
||||
I don't know what the weather outside is.
|
||||
@ -88,15 +88,15 @@ I don't know what the weather outside is.
|
||||
I have the following things:
|
||||
{{/has_things}}
|
||||
{{#things}}
|
||||
- Here's a thing: {{.}}
|
||||
- Here's a thing: {{{.}}}
|
||||
{{/things}}
|
||||
|
||||
{{#people}}
|
||||
- {{name}} is {{mood}}
|
||||
- {{{name}}} is {{{mood}}}
|
||||
{{/people}}
|
||||
```
|
||||
|
||||
In the first section, `name` is a key, and its value replaces `{{name}}`.
|
||||
In the first section, `name` is a key, and its value replaces `{{{name}}}`.
|
||||
|
||||
In the second section, `weather`'s value may or may not exist.
|
||||
If it does exist, then "It's $weather outside" is printed.
|
||||
@ -105,11 +105,16 @@ Mustache uses a notion of "truthiness" similar to Python or JavaScript, where va
|
||||
|
||||
In the third section, `has_things`' value is printed if it's truthy.
|
||||
Then, if the `things` list is truthy (i.e. not empty), its values are each printed on their own line.
|
||||
The reason that we have two separate keys is that `{{#things}}` iterates over the whole `things` list, even when there are no `{{.}}` placeholders, which would duplicate "I have the following things:" `n` times.
|
||||
The reason that we have two separate keys is that `{{#things}}` iterates over the whole `things` list, even when there are no `{{{.}}}` placeholders, which would duplicate "I have the following things:" `n` times.
|
||||
|
||||
The fourth section iterates over the `people` list, but instead of using the `{{.}}` placeholder, we have `name` and `mood`, which are keys or fields of the list elements.
|
||||
The fourth section iterates over the `people` list, but instead of using the `{{{.}}}` placeholder, we have `name` and `mood`, which are keys or fields of the list elements.
|
||||
Most types are supported here, including `Dict`s and structs.
|
||||
`NamedTuple`s require you to use `{{:name}}` instead of the normal `{{name}}`, though.
|
||||
`NamedTuple`s require you to use `{{{:name}}}` instead of the normal `{{{name}}}`, though.
|
||||
|
||||
You might notice that some curlies are in groups of two (`{{key}}`), and some are in groups of three (`{{{key}}}`).
|
||||
Whenever we want to subtitute in a value, using the triple curlies disables HTML escaping, which we rarely want for the types of files we're creating.
|
||||
If you do want escaping, just use the double curlies.
|
||||
And if you're using different delimiters, for example `<<foo>>`, use `<<&foo>>` to disable escaping.
|
||||
|
||||
Assuming the following view:
|
||||
|
||||
|
@ -9,7 +9,7 @@ using LibGit2: LibGit2, GitRemote
|
||||
using Pkg: Pkg, TOML, PackageSpec
|
||||
using REPL.TerminalMenus: MultiSelectMenu, RadioMenu, request
|
||||
|
||||
using Mustache: entityMap, render
|
||||
using Mustache: render
|
||||
using Parameters: @with_kw_noshow
|
||||
|
||||
export
|
||||
|
@ -167,7 +167,7 @@ Render a template file with the data in `view`.
|
||||
`tags` should be a tuple of two strings, which are the opening and closing delimiters, or `nothing` to use the default delimiters.
|
||||
"""
|
||||
function render_file(file::AbstractString, view::Dict{<:AbstractString}, tags)
|
||||
render_text(read(file, String), view, tags)
|
||||
return render_text(read(file, String), view, tags)
|
||||
end
|
||||
|
||||
"""
|
||||
@ -177,17 +177,7 @@ Render some text with the data in `view`.
|
||||
`tags` should be a tuple of two strings, which are the opening and closing delimiters, or `nothing` to use the default delimiters.
|
||||
"""
|
||||
function render_text(text::AbstractString, view::Dict{<:AbstractString}, tags=nothing)
|
||||
saved = copy(entityMap)
|
||||
empty!(entityMap)
|
||||
return try
|
||||
if tags === nothing
|
||||
render(text, view)
|
||||
else
|
||||
render(text, view; tags=tags)
|
||||
end
|
||||
finally
|
||||
append!(entityMap, saved)
|
||||
end
|
||||
return tags === nothing ? render(text, view) : render(text, view; tags=tags)
|
||||
end
|
||||
|
||||
include(joinpath("plugins", "defaults.jl"))
|
||||
|
@ -59,8 +59,8 @@ destination(::TravisCI) = ".travis.yml"
|
||||
|
||||
badges(::TravisCI) = Badge(
|
||||
"Build Status",
|
||||
"https://travis-ci.com/{{USER}}/{{PKG}}.jl.svg?branch=master",
|
||||
"https://travis-ci.com/{{USER}}/{{PKG}}.jl",
|
||||
"https://travis-ci.com/{{{USER}}}/{{{PKG}}}.jl.svg?branch=master",
|
||||
"https://travis-ci.com/{{{USER}}}/{{{PKG}}}.jl",
|
||||
)
|
||||
|
||||
function view(p::TravisCI, t::Template, pkg::AbstractString)
|
||||
@ -125,8 +125,8 @@ destination(::AppVeyor) = ".appveyor.yml"
|
||||
|
||||
badges(::AppVeyor) = Badge(
|
||||
"Build Status",
|
||||
"https://ci.appveyor.com/api/projects/status/github/{{USER}}/{{PKG}}.jl?svg=true",
|
||||
"https://ci.appveyor.com/project/{{USER}}/{{PKG}}-jl",
|
||||
"https://ci.appveyor.com/api/projects/status/github/{{{USER}}}/{{{PKG}}}.jl?svg=true",
|
||||
"https://ci.appveyor.com/project/{{{USER}}}/{{{PKG}}}-jl",
|
||||
)
|
||||
|
||||
function view(p::AppVeyor, t::Template, pkg::AbstractString)
|
||||
@ -178,8 +178,8 @@ destination(::CirrusCI) = ".cirrus.yml"
|
||||
|
||||
badges(::CirrusCI) = Badge(
|
||||
"Build Status",
|
||||
"https://api.cirrus-ci.com/github/{{USER}}/{{PACKAGE}}.jl.svg",
|
||||
"https://cirrus-ci.com/github/{{USER}}/{{PKG}}.jl",
|
||||
"https://api.cirrus-ci.com/github/{{{USER}}}/{{{PKG}}}.jl.svg",
|
||||
"https://cirrus-ci.com/github/{{{USER}}}/{{{PKG}}}.jl",
|
||||
)
|
||||
|
||||
function view(p::CirrusCI, t::Template, pkg::AbstractString)
|
||||
@ -230,13 +230,13 @@ destination(::GitLabCI) = ".gitlab-ci.yml"
|
||||
function badges(p::GitLabCI)
|
||||
ci = Badge(
|
||||
"Build Status",
|
||||
"https://gitlab.com/{{USER}}/{{PKG}}.jl/badges/master/build.svg",
|
||||
"https://gitlab.com/{{USER}}/{{PKG}}.jl/pipelines",
|
||||
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/badges/master/build.svg",
|
||||
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/pipelines",
|
||||
)
|
||||
cov = Badge(
|
||||
"Coverage",
|
||||
"https://gitlab.com/{{USER}}/{{PKG}}.jl/badges/master/coverage.svg",
|
||||
"https://gitlab.com/{{USER}}/{{PKG}}.jl/commits/master",
|
||||
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/badges/master/coverage.svg",
|
||||
"https://gitlab.com/{{{USER}}}/{{{PKG}}}.jl/commits/master",
|
||||
)
|
||||
return p.coverage ? [ci, cov] : [ci]
|
||||
end
|
||||
|
@ -17,8 +17,8 @@ destination(::Codecov) = ".codecov.yml"
|
||||
|
||||
badges(::Codecov) = Badge(
|
||||
"Coverage",
|
||||
"https://codecov.io/gh/{{USER}}/{{PKG}}.jl/branch/master/graph/badge.svg",
|
||||
"https://codecov.io/gh/{{USER}}/{{PKG}}.jl",
|
||||
"https://codecov.io/gh/{{{USER}}}/{{{PKG}}}.jl/branch/master/graph/badge.svg",
|
||||
"https://codecov.io/gh/{{{USER}}}/{{{PKG}}}.jl",
|
||||
)
|
||||
|
||||
"""
|
||||
@ -38,8 +38,8 @@ destination(::Coveralls) = ".coveralls.yml"
|
||||
|
||||
badges(::Coveralls) = Badge(
|
||||
"Coverage",
|
||||
"https://coveralls.io/repos/github/{{USER}}/{{PKG}}.jl/badge.svg?branch=master",
|
||||
"https://coveralls.io/github/{{USER}}/{{PKG}}.jl?branch=master",
|
||||
"https://coveralls.io/repos/github/{{{USER}}}/{{{PKG}}}.jl/badge.svg?branch=master",
|
||||
"https://coveralls.io/github/{{{USER}}}/{{{PKG}}}.jl?branch=master",
|
||||
)
|
||||
|
||||
gitignore(::Union{Codecov, Coveralls}) = COVERAGE_GITIGNORE
|
||||
|
@ -55,18 +55,18 @@ badges(::Documenter{TravisCI}) = [
|
||||
Badge(
|
||||
"Stable",
|
||||
"https://img.shields.io/badge/docs-stable-blue.svg",
|
||||
"https://{{USER}}.github.io/{{PKG}}.jl/stable",
|
||||
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/stable",
|
||||
),
|
||||
Badge(
|
||||
"Dev",
|
||||
"https://img.shields.io/badge/docs-dev-blue.svg",
|
||||
"https://{{USER}}.github.io/{{PKG}}.jl/dev",
|
||||
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/dev",
|
||||
),
|
||||
]
|
||||
badges(::Documenter{GitLabCI}) = Badge(
|
||||
"Dev",
|
||||
"https://img.shields.io/badge/docs-dev-blue.svg",
|
||||
"https://{{USER}}.gitlab.io/{{PKG}}.jl/dev",
|
||||
"https://{{{USER}}}.gitlab.io/{{{PKG}}}.jl/dev",
|
||||
)
|
||||
|
||||
view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
|
||||
|
2
test/fixtures/AllPlugins/README.md.txt
vendored
2
test/fixtures/AllPlugins/README.md.txt
vendored
@ -4,6 +4,6 @@
|
||||
[](https://gitlab.com/tester/AllPlugins.jl/commits/master)
|
||||
[](https://travis-ci.com/tester/AllPlugins.jl)
|
||||
[](https://ci.appveyor.com/project/tester/AllPlugins-jl)
|
||||
[](https://cirrus-ci.com/github/tester/AllPlugins.jl)
|
||||
[](https://cirrus-ci.com/github/tester/AllPlugins.jl)
|
||||
[](https://codecov.io/gh//.jl)
|
||||
[](https://coveralls.io/github//.jl?branch=master)
|
||||
|
Loading…
Reference in New Issue
Block a user