-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Template feature so documents can be generated using the built in functions #266
Merged
Merged
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1c8fba8
Added Template so data forms can be generated
eded472
Added template function and created new templates
206c9e7
Fixed a few template issues
caec57e
Test Runner
1c62e69
Updated the unit test
b2b7ee8
Merge pull request #1 from Mrpye/Dev
Mrpye fa6d6ee
Merge branch 'develop' into master
Mrpye c914287
Update README.md
Mrpye afd56ef
Added space in comments
f733281
Refined the Markdown and Email removed html
d0fd1b4
Delete .vscode directory
Mrpye 93bea95
readded
b05ed58
First set of clean up
b42894b
Update FUNDING.yml
brianvoe b744f4e
Added FixedWidth
2740337
Update of documents and test
457584a
Merge branch 'brianvoe:master' into master
Mrpye fb8b1db
Merge branch 'brianvoe:master' into dev
Mrpye ba788b0
Merge pull request #2 from Mrpye/dev
Mrpye fda9464
Fixed comments
16a2f6b
Fixed issue causing test to fail
5b9c7b5
Few small refactoring and clean up tweaks
25af77e
simplify parameters kept spacing, align
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package data | ||
|
||
// Email Template | ||
const email_template1 = `{{RandomString (ListS 'Hi' 'Hello' 'Dear' 'Good morning' 'Good afternoon' 'Good evening' )}}, {{$saved_to:=Person}}{{$saved_to.FirstName}}\n | ||
{{$res:=CreateListResult 1 7}}{{range $y := IntRange 1 .Lines}}{{$res = ListResult ($res) 1 7 true}}{{if eq $res.Value 1}}{{Paragraph (Number 1 3) (Number 3 5) (Number 10 20) '\n\n'}} | ||
{{end}}{{if eq $res.Value 2}}{{Question}}\n{{end}}{{if eq $res.Value 3}}{{Quote}}\n{{end}}{{if eq $res.Value 4}}{{HipsterParagraph (Number 1 3) (Number 3 5) (Number 10 20) '\n\n'}} | ||
{{end}}{{if eq $res.Value 5}}{{RandomString (ListS (conc 'Have you seen' (MovieName) 'it is' (AdjectiveDescriptive)) (conc 'Have you seen the' (MovieName) '?') (conc 'Do you want to watch' (MovieName) (AdverbTimeDefinite) '?') )}} | ||
{{end}}{{if eq $res.Value 6}}{{conc (PronounPersonal) (VerbHelping) (VerbIntransitive) (AdverbTimeDefinite) (PronounDemonstrative) (AdverbFrequencyIndefinite) 'Happens' (AdverbTimeDefinite)}}\n{{end}}{{if eq $res.Value 7}}{{HipsterSentence (Number 10 20)}}{{end}}{{end}} | ||
{{$saved_from:=Person}}{{RandomString (ListS 'Regards' 'Sincerely' 'Best wishes' 'Cheers' 'Take care' 'Best' 'Thank you' 'I appreciate your help' 'I appreciate your feedback' 'I appreciate your input')}}\n{{$saved_from.FirstName}}{{if Bool}} {{$saved_from.LastName}}{{end}}\n{{if Bool}}{{if Bool}}\nCompany: {{$saved_from.Job.Company}}\nJob Role: {{$saved_from.Job.Title}}\n{{end}} | ||
{{if Bool}}Address: {{$saved_from.Address.Address}}\nCity: {{$saved_from.Address.City}}\nState: {{$saved_from.Address.State}}\nZip: {{$saved_from.Address.Zip}}{{end}}Phone: {{$saved_from.Contact.Phone}}\nEmail: {{$saved_from.Contact.Email}}{{end}}` | ||
|
||
// Markdown Template | ||
const markdown_body1 = `{{$res:=CreateListResult 1 7}} | ||
{{range $y := IntRange 1 .Lines}}{{$res = ListResult ($res) 1 7 true}}{{if eq $res.Value 1}}# Paragraph | ||
|
||
{{Paragraph (Number 1 5) (Number 1 5) (Number 1 30) '\n\n'}} | ||
|
||
--- | ||
{{end}}{{if eq $res.Value 2}}# Block Quote | ||
|
||
{{Paragraph (Number 1 5) (Number 1 5) (Number 1 30) '\n\n'}} | ||
|
||
--- | ||
{{end}}{{if eq $res.Value 3}}## Details | ||
|
||
{{Paragraph (Number 1 5) (Number 1 5) (Number 1 30) '\n\n'}} | ||
|
||
<details> | ||
<summary>{{SentenceSimple}} </summary> | ||
|
||
''' | ||
go install {{URL}} | ||
''' | ||
|
||
</details> | ||
|
||
--- | ||
{{end}}{{if eq $res.Value 4}}## Url | ||
|
||
Golang you will need to install | ||
|
||
{{range $y := IntRange 1 (Number 1 10)}}[{{$saved_url:=URL}}{{$saved_url}}]({{$saved_url}}) | ||
{{end}} | ||
--- | ||
{{end}}{{if eq $res.Value 5}}## LISTS | ||
|
||
{{Paragraph (Number 1 5) (Number 1 5) (Number 1 30) '\n\n'}}. | ||
|
||
{{range $y := IntRange 1 (Number 1 10)}}1. {{PhraseVerb}} | ||
{{end}} | ||
--- | ||
{{end}}{{if eq $res.Value 6}}## Images | ||
|
||
{{Paragraph (Number 1 5) (Number 1 5) (Number 10 30) '\n\n'}}. | ||
|
||
{{range $y := IntRange 1 (Number 1 2)}}<image src="data:image/png;base64,{{Base64Enc (ImagePng 50 50)}}"" width="200" height="200" alt/><em>{{AdjectiveProper}}</em> | ||
{{end}} | ||
--- | ||
{{end}}{{if eq $res.Value 7}}## Code Examples {{$data_type:=RandomString (ListS 'Int' 'Float32' 'Float64' 'Uint32' 'Int63' )}} | ||
|
||
''' | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
// GenerateRandom{{$data_type}} generates a random {{lc ($data_type)}} between min and max (inclusive). | ||
// | ||
// Parameters: | ||
// min ({{lc ($data_type)}}): The minimum value of the random {{lc ($data_type)}}. | ||
// max ({{lc ($data_type)}}): The maximum value of the random {{lc ($data_type)}}. | ||
// | ||
// Returns: | ||
// int: A random {{lc ($data_type)}} between min and max (inclusive). | ||
func GenerateRandom{{$data_type}}(min, max {{lc ($data_type)}}) {{lc ($data_type)}} { | ||
rand.Seed(time.Now().UnixNano()) | ||
return min + rand.{{$data_type}}()*(max-min) | ||
} | ||
|
||
func main() { | ||
random{{$data_type}} := GenerateRandom{{$data_type}} (1, 10) | ||
fmt.Printf("Random {{$data_type}}: %d'|n'", random{{$data_type}}) | ||
} | ||
|
||
''' | ||
|
||
---{{end}} | ||
{{end}}` | ||
|
||
// template contains golang templates | ||
var Template = map[string][]string{ | ||
"email": {email_template1}, | ||
"markdown": {markdown_body1}, | ||
"document": {email_template1, markdown_body1}, | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TemplateEmailText - lets change it to TemplateEmailText for now in the event we do an html version in the future.