-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d33f8f
commit 83aaac1
Showing
12 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package renderhtml | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"html/template" | ||
"log" | ||
"strings" | ||
) | ||
|
||
var tAbbr *template.Template | ||
|
||
type AbbrParams struct { | ||
Class template.HTMLAttr | ||
InnerHtml template.HTML | ||
Text template.HTML | ||
Title template.HTMLAttr | ||
} | ||
|
||
func RenderAbbr(params *AbbrParams) (string, error) { | ||
if params.InnerHtml != "" && params.Text != "" { | ||
return "", errors.New("in an abbr tag, either InnerHtml or Text must be set") | ||
} | ||
var b bytes.Buffer | ||
err := tAbbr.Execute(&b, params) | ||
if err != nil { | ||
return "", err | ||
} | ||
return b.String(), nil | ||
} | ||
|
||
func init() { | ||
var err error | ||
tAbbr, err = template.ParseFiles("./revamp/preprocessors/src/helpers/render_html/templates/abbr.tmpl") | ||
if err != nil && strings.Contains(err.Error(), "no such file") { | ||
tAbbr, err = template.ParseFiles("../../helpers/render_html/templates/abbr.tmpl") | ||
} | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
revamp/preprocessors/src/helpers/render_html/templates/abbr.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<abbr class="{{ .Class }}" title="{{ .Title }}">{{if .InnerHtml}}{{.InnerHtml}}{{else}}{{.Text}}{{end}}</abbr> |
5 changes: 4 additions & 1 deletion
5
revamp/preprocessors/src/helpers/render_html/templates/span.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
<p style="{{ .Style }}">{{ .Text }}</p> | ||
<p | ||
class="{{ .Class }}" | ||
style="{{ .Style }}" | ||
>{{ .Text }}</p> |
10 changes: 10 additions & 0 deletions
10
revamp/preprocessors/src/run-macros/macros/experimental_inline.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package macros | ||
|
||
import ( | ||
"webdoky3/revamp/preprocessors/src/run-macros/environment" | ||
"webdoky3/revamp/preprocessors/src/run-macros/registry" | ||
) | ||
|
||
func experimental_inline(env *environment.Environment, reg *registry.Registry, _ string) (string, error) { | ||
return experimentalbadge(env, reg, "") | ||
} |
24 changes: 24 additions & 0 deletions
24
revamp/preprocessors/src/run-macros/macros/experimentalbadge.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package macros | ||
|
||
import ( | ||
"html/template" | ||
renderhtml "webdoky3/revamp/preprocessors/src/helpers/render_html" | ||
"webdoky3/revamp/preprocessors/src/run-macros/environment" | ||
"webdoky3/revamp/preprocessors/src/run-macros/registry" | ||
) | ||
|
||
func experimentalbadge(env *environment.Environment, reg *registry.Registry, _ string) (string, error) { | ||
// span, err := renderhtml.RenderSpan(&renderhtml.SpanParams{ | ||
// Class: template.HTMLAttr("visually-hidden"), | ||
// Text: "Експериментальне", | ||
// }) | ||
// if err != nil { | ||
// return "", err | ||
// } | ||
return renderhtml.RenderAbbr(&renderhtml.AbbrParams{ | ||
Class: template.HTMLAttr("icon icon-experimental"), | ||
// InnerHtml: template.HTML(span), | ||
Text: "Експериментальне", | ||
Title: template.HTMLAttr("Експериментальне. Поведінка цієї можливості в майбутньому може змінитися."), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.