Skip to content

Conversation

@araluce
Copy link
Member

@araluce araluce commented Sep 22, 2025

There are two changes in this request:

  1. The sanitize helper now performs a more thorough sanitization and is ready to accept different types of objects. (We moved the enhanced sanitise from templates to the generic helper).
  2. Sanitization options can now be added to the insertHTML and render helpers.

@araluce araluce requested a review from markets September 22, 2025 09:11
}

// For primitives (numbers, booleans, etc.), return as-is
return data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@araluce maybe we should move here too this code block still in templates?

// Handle null and undefined values in output by replacing them with empty string
if (typeof output === 'string') {
  return output.replace(/\bnull\b/g, '').replace(/\bundefined\b/g, '')
}

insertTemplate(query, template, data, position = null) {
const html = render(template, data)
insertTemplate(query, template, data, options = {}) {
const defaults = { sanitize: true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original idea of this method is to use with "sanitize false", as we only need to sanitize data, the template is controlled by us. Otherwise I'm not sure if this method makes sense 🤔?

In general, I'd like to keep Ralix rendering as safe as possible by default, but at the same time we need to provide good ergonomics to work with the framework (passing "sanitize false" seems like an exception).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants