-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRazor-Language.ps1
More file actions
43 lines (36 loc) · 1.37 KB
/
Copy pathRazor-Language.ps1
File metadata and controls
43 lines (36 loc) · 1.37 KB
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
function Language.Razor {
<#
.SYNOPSIS
Razor PipeScript Language Definition.
.DESCRIPTION
Allows PipeScript to generate Razor.
Multiline comments blocks like this ```<!--{}-->``` will be treated as blocks of PipeScript.
JavaScript/CSS comment blocks like ```/*{}*/``` will also be treated as blocks of PipeScript.
Razor comment blocks like ```@*{}*@``` will also be treated as blocks of PipeScript.
#>
[ValidatePattern('\.(cshtml|razor)$')]
param()
$this = $myInvocation.MyCommand
if (-not $this.Self) {
$languageDefinition = New-Module {
param(
)
$FilePattern = '\.(cshtml|razor)$'
# We start off by declaring a number of regular expressions:
$startComment = '(?><\!--|/\*|\@\*)'
$endComment = '(?>-->|\*/|\*@)'
$Whitespace = '[\s\n\r]{0,}'
# * StartPattern ```$StartComment + '{' + $Whitespace```
$startPattern = "(?<PSStart>${startComment}\{$Whitespace)"
# * EndPattern ```$whitespace + '}' + $EndComment```
$endPattern = "(?<PSEnd>$Whitespace\}${endComment}\s{0,})"
$LanguageName = 'Razor'
Export-ModuleMember -Variable * -Function * -Alias *
} -AsCustomObject
$languageDefinition.pstypenames.clear()
$languageDefinition.pstypenames.add("Language")
$languageDefinition.pstypenames.add("Language.Razor")
$this.psobject.properties.add([PSNoteProperty]::new('Self',$languageDefinition))
}
$this.Self
}