mirror of
https://github.com/hexastack/hexabot
synced 2025-04-16 21:56:00 +00:00
fix: typo naming
This commit is contained in:
parent
3ca4ca0e2b
commit
481851f713
@ -34,7 +34,7 @@ The envelope helpers introduces two key components to streamline outgoing messag
|
|||||||
|
|
||||||
- **Template Conversion & Compilation:**
|
- **Template Conversion & Compilation:**
|
||||||
- **toHandlebars:** Converts legacy single-curly brace templates (e.g., `{context.user.name}`) into Handlebars-style (`{{context.user.name}}`).
|
- **toHandlebars:** Converts legacy single-curly brace templates (e.g., `{context.user.name}`) into Handlebars-style (`{{context.user.name}}`).
|
||||||
- **compileHandlerbarsTemplate:** Compiles and processes these templates by injecting contextual data, allowing dynamic content generation.
|
- **compileHandlebarsTemplate:** Compiles and processes these templates by injecting contextual data, allowing dynamic content generation.
|
||||||
|
|
||||||
- **Localization:**
|
- **Localization:**
|
||||||
Processes input text for localization using an integrated i18n service, ensuring that messages are tailored to the user's language settings.
|
Processes input text for localization using an integrated i18n service, ensuring that messages are tailored to the user's language settings.
|
||||||
|
@ -92,12 +92,12 @@ describe('EnvelopeFactory', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('compileHandlerbarsTemplate', () => {
|
describe('compileHandlebarsTemplate', () => {
|
||||||
it('should replace tokens with context variables correctly', () => {
|
it('should replace tokens with context variables correctly', () => {
|
||||||
const text =
|
const text =
|
||||||
'Hello {{context.user.first_name}} {{context.user.last_name}}, your phone is {{context.vars.phone}}';
|
'Hello {{context.user.first_name}} {{context.user.last_name}}, your phone is {{context.vars.phone}}';
|
||||||
|
|
||||||
const result = EnvelopeFactory.compileHandlerbarsTemplate(
|
const result = EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
text,
|
text,
|
||||||
context,
|
context,
|
||||||
settings,
|
settings,
|
||||||
@ -121,7 +121,7 @@ describe('EnvelopeFactory', () => {
|
|||||||
contact: {},
|
contact: {},
|
||||||
} as unknown as Settings;
|
} as unknown as Settings;
|
||||||
|
|
||||||
const result = EnvelopeFactory.compileHandlerbarsTemplate(
|
const result = EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
text,
|
text,
|
||||||
context,
|
context,
|
||||||
settings,
|
settings,
|
||||||
@ -133,7 +133,7 @@ describe('EnvelopeFactory', () => {
|
|||||||
|
|
||||||
it('should use contact from settings if provided', () => {
|
it('should use contact from settings if provided', () => {
|
||||||
const text = 'You can reach us at {{contact.company_email}}';
|
const text = 'You can reach us at {{contact.company_email}}';
|
||||||
const result = EnvelopeFactory.compileHandlerbarsTemplate(
|
const result = EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
text,
|
text,
|
||||||
context,
|
context,
|
||||||
settings,
|
settings,
|
||||||
@ -143,7 +143,7 @@ describe('EnvelopeFactory', () => {
|
|||||||
|
|
||||||
it('should handle no placeholders gracefully', () => {
|
it('should handle no placeholders gracefully', () => {
|
||||||
const text = 'No placeholders here.';
|
const text = 'No placeholders here.';
|
||||||
const result = EnvelopeFactory.compileHandlerbarsTemplate(
|
const result = EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
text,
|
text,
|
||||||
context,
|
context,
|
||||||
settings,
|
settings,
|
||||||
|
@ -68,7 +68,7 @@ export class EnvelopeFactory {
|
|||||||
*
|
*
|
||||||
* @returns Text message with the tokens being replaced
|
* @returns Text message with the tokens being replaced
|
||||||
*/
|
*/
|
||||||
static compileHandlerbarsTemplate(
|
static compileHandlebarsTemplate(
|
||||||
text: string,
|
text: string,
|
||||||
context: Context,
|
context: Context,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
@ -99,7 +99,7 @@ export class EnvelopeFactory {
|
|||||||
lang: this.context.user.language,
|
lang: this.context.user.language,
|
||||||
defaultValue: result,
|
defaultValue: result,
|
||||||
});
|
});
|
||||||
result = EnvelopeFactory.compileHandlerbarsTemplate(
|
result = EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
result,
|
result,
|
||||||
this.context,
|
this.context,
|
||||||
this.settings,
|
this.settings,
|
||||||
|
@ -390,7 +390,7 @@ export class BlockService extends BaseService<
|
|||||||
subscriberContext: SubscriberContext,
|
subscriberContext: SubscriberContext,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
): string {
|
): string {
|
||||||
return EnvelopeFactory.compileHandlerbarsTemplate(
|
return EnvelopeFactory.compileHandlebarsTemplate(
|
||||||
text,
|
text,
|
||||||
{
|
{
|
||||||
...context,
|
...context,
|
||||||
|
Loading…
Reference in New Issue
Block a user