Issue with PREVIEW_MAX_LENGTH Truncating Template Strings #1260
ismoiliy98
started this conversation in
Ideas
Replies: 2 comments
-
Increasing the max length in any form might not be the best idea because we pad the preview text with white space characters and a different max length might cause problems. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Converting this into a discussion here as it is mostly an idea. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
I'm encountering an issue with the
Preview
component in the@react-email/components
package when using SparkPost's templating language. Specifically, the component truncates the template strings beyond a certain length, leading to invalid and non-functional templates due to errors in the templating language.This limitation adversely affects the usability of the
Preview
component for users who rely on longer template strings. To address this, I propose two potential solutions:Removing or Extending the Maximum Length Limit: Consider removing or significantly increasing the maximum length limitation on the
Preview
component's text input. This change would accommodate more complex templates that require longer strings.Customizable Maximum Length via Props: Alternatively, introduce a prop that allows users to specify a custom maximum length for their template strings. This approach provides flexibility and caters to various use cases without imposing a rigid limit.
Example for illustration
Input Template String:
Hello, {{if auth and auth.userName}}{{auth.userName}}{{else}}Guest{{end}}. Your login code is {{if auth and auth.loginCode}}{{auth.loginCode}}{{else}}EXAMPLE{{end}}
Current Output with Truncation:
Hello, {{if auth and auth.userName}}{{auth.userName}}{{else}}Guest{{end}}. Your login code is {{if auth and auth.loginCode}}{{auth.loginCode}}{{else}}
Expected Output Without Truncation:
Hello, {{if auth and auth.userName}}{{auth.userName}}{{else}}Guest{{end}}. Your login code is {{if auth and auth.loginCode}}{{auth.loginCode}}{{else}}EXAMPLE{{end}}
In the current state, the template string is truncated to a maximum of 150 characters, resulting in the removal of essential parts of the template. This truncation renders the template ineffective and leads to errors in the templating language processing.
I believe addressing this issue will significantly enhance the functionality and flexibility of the
Preview
component for users working with complex email templates. Thank you for considering this enhancement.Beta Was this translation helpful? Give feedback.
All reactions