Last active
January 5, 2025 20:26
-
-
Save dave256/7b4b42b4d20fd56c597a016826175cec to your computer and use it in GitHub Desktop.
example TextExpander JavaScript snippet with fill-ins
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
// more info at this post: https://blog.dave256apps.com/2025/01/05/textexpander-javascript-snippets.html | |
function capitalizeFirstLetter(input) { | |
// Capitalize the first letter and append the rest of the string | |
return input.charAt(0).toUpperCase() + input.slice(1); | |
} | |
let filename = "%filltext:name=filename:width=20%"; | |
let capitalizedFilename = capitalizeFirstLetter(filename); | |
let output = `#!/usr/bin/env python3 | |
# ---------------------------------------------------------------------- | |
# test_${filename}.py | |
# Dave Reed | |
# | |
# ---------------------------------------------------------------------- | |
import unittest | |
from ${filename} import * | |
# ---------------------------------------------------------------------- | |
class ${capitalizedFilename}Test(unittest.TestCase): | |
def test1(self): | |
pass | |
def test2(self): | |
pass | |
def test3(self): | |
pass | |
# ---------------------------------------------------------------------- | |
if __name__ == '__main__': | |
unittest.main() | |
`; | |
output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment