-
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
3df0e35
commit 890b01c
Showing
7 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ class="{{.Class}}" | |
height="{{.Height}}" | ||
src="{{.Src}}" | ||
title="{{.Title}}" | ||
width="{{.Width}}" | ||
></iframe> |
44 changes: 44 additions & 0 deletions
44
revamp/preprocessors/src/run-macros/macros/embedghlivesample.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,44 @@ | ||
package macros | ||
|
||
import ( | ||
"errors" | ||
"html/template" | ||
"strings" | ||
preprocessor_helpers "webdoky3/revamp/preprocessors/src/helpers" | ||
renderhtml "webdoky3/revamp/preprocessors/src/helpers/render_html" | ||
"webdoky3/revamp/preprocessors/src/run-macros/environment" | ||
"webdoky3/revamp/preprocessors/src/run-macros/registry" | ||
) | ||
|
||
func parseEmbedghlivesampleArgs(args string) (string, string, string, error) { | ||
// args: "path,width,height" | ||
// Split the args string into a slice of strings | ||
// using the comma as the separator | ||
// (e.g., "path,width,height" -> ["path", "width", "height"]) | ||
argSlice := strings.Split(args, ",") | ||
switch len(argSlice) { | ||
case 0: | ||
return "", "", "", errors.New("no arguments") | ||
case 1: | ||
return preprocessor_helpers.UnwrapString(argSlice[0]), "", "", nil | ||
case 2: | ||
return preprocessor_helpers.UnwrapString(argSlice[0]), preprocessor_helpers.UnwrapString(argSlice[1]), "", nil | ||
case 3: | ||
return preprocessor_helpers.UnwrapString(argSlice[0]), preprocessor_helpers.UnwrapString(argSlice[1]), preprocessor_helpers.UnwrapString(argSlice[2]), nil | ||
default: | ||
return "", "", "", errors.New("too many arguments") | ||
} | ||
} | ||
|
||
func embedghlivesample(env *environment.Environment, _ *registry.Registry, args string) (string, error) { | ||
path, width, height, err := parseEmbedghlivesampleArgs(args) | ||
if err != nil { | ||
return "", err | ||
} | ||
return renderhtml.RenderIframe(&renderhtml.IframeParams{ | ||
Height: template.HTMLAttr(height), | ||
Src: template.HTMLAttr("https://webdoky.github.io/" + path), | ||
Width: template.HTMLAttr(width), | ||
}) | ||
|
||
} |
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