Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course Catalog - Line breaks in Course Description field breaks JS required for search #2

Open
megoconnor opened this issue Jun 10, 2020 · 1 comment

Comments

@megoconnor
Copy link

Description

If line breaks are added in the Course Description field for Course pages, those line breaks are output in the JS that powers the search. You'll receive the following error in the developer console when attempting to search:

tipuesearch_content.js:6
Uncaught SyntaxError: Invalid or unexpected token

Workaround

Sanitize the Course Description field for JSON in the _cms/formats/velocity/search-content-js Format.

Setting the variable on Line 10:

#set ( $desc = $_EscapeTool.xml($data.getChild("description").value) )

Output on Line 18:

"text": "#sanitizeJsonValue($desc)"

Macro:

#macro (sanitizeJsonValue $value)$value.replaceAll("([\t\r\n]|(\s{2,}))", "")#end
@megoconnor
Copy link
Author

megoconnor commented Jun 16, 2020

Ticket gz#12500

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

No branches or pull requests

1 participant