Skip to content

Instantly share code, notes, and snippets.

@dave256
Last active January 5, 2025 20:26
Show Gist options
  • Save dave256/7b4b42b4d20fd56c597a016826175cec to your computer and use it in GitHub Desktop.
Save dave256/7b4b42b4d20fd56c597a016826175cec to your computer and use it in GitHub Desktop.
example TextExpander JavaScript snippet with fill-ins
// 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