@phillipsharring/graspr-framework 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phillip Harrington
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillipsharring/graspr-framework",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "HTMX + Handlebars + Tailwind frontend framework",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Register A/B testing Handlebars helpers.
3
+ *
4
+ * Usage in templates:
5
+ * {{#ab "test-name" "a"}}...content for variant a...{{/ab}}
6
+ * {{#ab "test-name" "b"}}...content for variant b...{{/ab}}
7
+ *
8
+ * The template context must include an `ab` object mapping test names to assigned variants.
9
+ * This is typically set on the rendering context before template execution.
10
+ *
11
+ * @param {typeof import('handlebars')} Handlebars
12
+ */
13
+ export function registerAbHelpers(Handlebars) {
14
+ /**
15
+ * Block helper: renders content only if the visitor's assignment matches.
16
+ *
17
+ * @example
18
+ * {{#ab "headline" "a"}}<h1>Original headline</h1>{{/ab}}
19
+ * {{#ab "headline" "b"}}<h1>New headline</h1>{{/ab}}
20
+ */
21
+ Handlebars.registerHelper('ab', function (testName, variant, options) {
22
+ // `this` is the Handlebars context — look for ab assignments
23
+ var assignments = this.ab || {};
24
+ if (assignments[testName] === variant) {
25
+ return options.fn(this);
26
+ }
27
+ return '';
28
+ });
29
+ }
package/src/index.js CHANGED
@@ -66,6 +66,7 @@ export { createTypeahead } from './ui/typeahead.js';
66
66
 
67
67
  // Helpers
68
68
  export { registerHandlebarsHelpers } from './helpers/handlebars-helpers.js';
69
+ export { registerAbHelpers } from './helpers/ab-helpers.js';
69
70
  export { initCopyIdHandler } from './helpers/utils.js';
70
71
  export { escapeHtml } from './helpers/escape-html.js';
71
72
  export { populateSelect } from './helpers/populate-select.js';