Skip to content

Commit

Permalink
feat: Porting Razor Template to Language Function (Fixes #620)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Nov 12, 2023
2 parents 9e2b030 + ee63d9c commit 7beba5c
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/Language.BASIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rem }
Invoke-PipeScript {
$VBScript = '
rem {
Uncommented lines between these two points will be ignored
rem # Uncommented lines between these two points will be ignored
rem # Commented lines will become PipeScript / PowerShell.
rem param($message = "hello world")
rem "CreateObject(`"WScript.Shell`").Popup(`"$message`")"
Expand Down
2 changes: 1 addition & 1 deletion docs/Language.Batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Because Batch Scripts only allow single-line comments, this is done using a pair

```batch
:: {
Uncommented lines between these two points will be ignored
:: Uncommented lines between these two points will be ignored
:: # Commented lines will become PipeScript / PowerShell.
:: param($message = 'hello world')
:: "echo $message"
Expand Down
31 changes: 31 additions & 0 deletions docs/Language.PowerShellData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Language.PowerShellData
-----------------------




### Synopsis
PSD1 Template Transpiler.



---


### Description

Allows PipeScript to generate PSD1.
Multiline comments blocks enclosed with {} will be treated as Blocks of PipeScript.
Multiline comments can be preceeded or followed by single-quoted strings, which will be ignored.
* ```''```
* ```{}```



---


### Syntax
```PowerShell
Language.PowerShellData [<CommonParameters>]
```
51 changes: 51 additions & 0 deletions docs/Language.Python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Language.Python
---------------




### Synopsis
Python Language Definition.



---


### Description

Allows PipeScript to generate Python.
Because Python does not support multiline comment blocks, PipeScript can be written inline inside of multiline string
PipeScript can be included in a Python string that starts and ends with ```{}```, for example ```"""{}"""```



---


### Examples
> EXAMPLE 1
```PowerShell
{
$pythonContent = @'
"""{
$msg = "Hello World", "Hey There", "Howdy" | Get-Random
@"
print("$msg")
"@
}"""
'@
[OutputFile('.\HelloWorld.ps1.py')]$PythonContent
}
.> .\HelloWorld.ps1.py
```


---


### Syntax
```PowerShell
Language.Python [<CommonParameters>]
```
60 changes: 60 additions & 0 deletions docs/Language.R.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Language.R
----------




### Synopsis
R Language Definition.



---


### Description

Allows PipeScript to generate R.
Because R Scripts only allow single-line comments, this is done using a pair of comment markers.
# { or # PipeScript{ begins a PipeScript block
# } or # }PipeScript ends a PipeScript block
~~~r
# {
Uncommented lines between these two points will be ignored
# # Commented lines will become PipeScript / PowerShell.
# param($message = "hello world")
# "puts `"$message`""
# }
~~~



---


### Examples
> EXAMPLE 1
```PowerShell
Invoke-PipeScript {
$rScript = '
# {
Uncommented lines between these two points will be ignored
# # Commented lines will become PipeScript / PowerShell.
# param($message = "hello world")
# "print(`"$message`")"
# }
'
[OutputFile('.\HelloWorld.ps1.r')]$rScript
}
Invoke-PipeScript .\HelloWorld.ps1.r
```


---


### Syntax
```PowerShell
Language.R [<CommonParameters>]
```
31 changes: 31 additions & 0 deletions docs/Language.Racket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Language.Racket
---------------




### Synopsis
Racket Template Transpiler.



---


### Description

Allows PipeScript to generate Racket.
Multiline comments blocks enclosed with {} will be treated as Blocks of PipeScript.
Multiline comments can be preceeded or followed by single-quoted strings, which will be ignored.
* ```''```
* ```{}```



---


### Syntax
```PowerShell
Language.Racket [<CommonParameters>]
```
3 changes: 0 additions & 3 deletions docs/ListOfTranspilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ These are all of the transpilers currently included in PipeScript:
|[PipeScript.TypeConstraint](Transpilers/Core/PipeScript.TypeConstraint.psx.ps1) |Transpiles Type Constraints |
|[PipeScript.TypeExpression](Transpilers/Core/PipeScript.TypeExpression.psx.ps1) |The PipeScript TypeExpression Transpiler |
|[ProxyCommand](Transpilers/ProxyCommand.psx.ps1) |Creates Proxy Commands |
|[PSD1.Template](Transpilers/Templates/PSD1.Template.psx.ps1) |PSD1 Template Transpiler. |
|[Python.Template](Transpilers/Templates/Python.Template.psx.ps1) |Python Template Transpiler. |
|[R.Template](Transpilers/Templates/R.Template.psx.ps1) |R Template Transpiler. |
|[Racket.Template](Transpilers/Templates/Racket.Template.psx.ps1) |Racket Template Transpiler. |
|[Razor.Template](Transpilers/Templates/Razor.Template.psx.ps1) |Razor Template Transpiler. |
|[RegexLiteral](Transpilers/Syntax/RegexLiteral.psx.ps1) |Regex Literal Transpiler |
|[RemoveParameter](Transpilers/Parameters/RemoveParameter.psx.ps1) |Removes Parameters from a ScriptBlock |
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Often, programming involves implementing small functional changes within a speci

For example, if implementing an interface or subclass, the only things that will change are the class name and method details.

PipeScript can be be embedded within 17 languages.
PipeScript can be be embedded within 14 languages.

Embedding PipeScript within any of these languages allows you to generate any of these languages with parameterized scripts, thus removing some of the tedium of programming.

Expand Down
3 changes: 0 additions & 3 deletions docs/SupportedLanguages.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ These are all of the transpilers currently included in PipeScript:

|Language |Synopsis |Pattern |
|--------------------------------------------------------------------------|--------------------------------|-------------------------|
|[PSD1.Template](Transpilers/Templates/PSD1.Template.psx.ps1) |PSD1 Template Transpiler. |```\.psd1$``` |
|[Python.Template](Transpilers/Templates/Python.Template.psx.ps1) |Python Template Transpiler. |```\.py$``` |
|[R.Template](Transpilers/Templates/R.Template.psx.ps1) |R Template Transpiler. |```\.r$``` |
|[Racket.Template](Transpilers/Templates/Racket.Template.psx.ps1) |Racket Template Transpiler. |```\.rkt$``` |
|[Razor.Template](Transpilers/Templates/Razor.Template.psx.ps1) |Razor Template Transpiler. |```\.(cshtml\\|razor)$```|
|[RSS.Template](Transpilers/Templates/RSS.Template.psx.ps1) |RSS Template Transpiler. |```\.rss$``` |
|[Ruby.Template](Transpilers/Templates/Ruby.Template.psx.ps1) |Ruby Template Transpiler. |```\.rb$``` |
Expand Down

0 comments on commit 7beba5c

Please sign in to comment.