Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
filfreire committed Dec 2, 2024
1 parent 944964b commit 8d929b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/insomnia/src/templating/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export function unTokenizeTag(tagData: NunjucksParsedTag) {
const q = arg.quotedBy || "'";
const re = new RegExp(`([^\\\\])${q}`, 'g');
const str = arg.value?.toString().replace(re, `$1\\${q}`);
args.push(`${q}${str}${q}`);
console.log('debug-unTokenizeTag-for-cycle', { arg, str });
args.push(String.raw`${q}${str}${q}`);
} else if (arg.type === 'boolean') {
args.push(arg.value ? 'true' : 'false');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ async function _updateElementText(
let dataIgnore = '';
let dataError = '';
const str = text.replace(/\\/g, ''); // TODO-filipe: possible culprit??
console.log('debug-updateElementText', text, str);
const tagMatch = str.match(/{% *([^ ]+) *.*%}/);
const cleanedStr = str
.replace(/^{%/, '')
Expand All @@ -290,9 +291,11 @@ async function _updateElementText(

try {
if (tagMatch) {
console.log('debug-tagMatch', text, str, cleanedStr);
console.log('debug-tagMatch', text, 'str', str, 'cleanedStr', cleanedStr); // TODO-filipe: str and cleanedStr makes the \ disappear,

Check failure on line 294 in packages/insomnia/src/ui/components/codemirror/extensions/nunjucks-tags.ts

View workflow job for this annotation

GitHub Actions / Test

Trailing spaces not allowed
// TODO-filipe but re-adding it messes up the rendering?
const tagData = tokenizeTag(str);
const tagDefinition = (await getTagDefinitions()).find(d => d.name === tagData.name);
console.log('debug-tagDefinition', tagData, tagDefinition);

if (tagDefinition) {
// Try rendering these so we can show errors if needed
Expand All @@ -314,6 +317,7 @@ async function _updateElementText(
}

const preview = await render(text);
console.log('debug-preview', preview);
// @ts-expect-error -- TSCONVERSION
title = tagDefinition.disablePreview(tagData.args) ? preview.replace(/./g, '*') : preview;
} else {
Expand All @@ -324,6 +328,7 @@ async function _updateElementText(
} else {
// Render if it's a variable
title = await render(str);
console.log('debug-title', title);
const context = await renderContext();
const con = context.context.getKeysContext();
const contextForKey = con.keyContext[cleanedStr];
Expand Down

0 comments on commit 8d929b4

Please sign in to comment.