-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnippetInject.cshtml
42 lines (39 loc) · 1.06 KB
/
SnippetInject.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@inherits AppCode.Razor.AppRazor
@using ToSic.Razor.Blade
@using AppCode.Data
@{
// Detect what kind of snippet this is (js, html, css)
var snippetType = MyView.Identifier;
// Disable quality-check which otherwise warns 2sxc-developers that inline scripts shouldn't be used
// 2sxclint:disable:no-inline-script
}
@* Add editing section above the content for admins, because the snippet (js/css) is invisible *@
@if (MyUser.IsContentAdmin) {
<div class='app-snippetinject3-edit' @Kit.Toolbar.Default(MyItem)>
@App.Resources.DoNotDeleteWarning
</div>
<style>
.app-snippetinject3-edit {
color: #856404;
background-color: #fff3cd;
padding: .75rem 1.25rem;
margin-bottom: 1rem;
border-radius: .25rem;
display: flex;
justify-content: space-between;
}
</style>
}
@if (snippetType == "html") {
@MyItem.Html("Html", container:"")
}
@if (snippetType == "css") {
<style>
@MyItem.Html("Styles", container:"")
</style>
}
@if (snippetType == "js") {
<script>
@MyItem.Html("Script", container:"")
</script>
}