-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed extra line before main fn (#272)
* Removed extra line before main fn * removed extra line in trainers.py * - Refactored store.js into two files: store.js and codegen.js - fixed code rendering issue with additional new lines
- Loading branch information
Showing
15 changed files
with
94 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// @ts-check | ||
import ejs from 'ejs' | ||
|
||
// merges the code from the common and specific files using ejs | ||
export function mergeCode(specificFileText, commonFileText) { | ||
const replaced = specificFileText.replace( | ||
/#::= from_template_common ::#\n/g, | ||
commonFileText | ||
) | ||
return replaced | ||
} | ||
|
||
export function renderCode(code, config) { | ||
// code = code | ||
// .replace(/({ :::#[\n\s]+)/gi, '{ :::#') | ||
// .replace(/([\s\n]+#:::\s}\s:::#)/gi, '#::: } :::#') | ||
|
||
// replace `\s(s) or \n(s)#:::\s` | ||
// with `#::: ` | ||
code = code.replace(/([\s\n]+#:::\s)/gi, '#::: ') | ||
|
||
return ejs.render(code, config).replace(/ # usort: skip/g, '') | ||
} | ||
|
||
// render the code if there are fetched files for current selected template | ||
export function generateFiles(currentFiles, store) { | ||
for (const file in currentFiles) { | ||
if (!store.config.include_test && file === 'test_all.py') { | ||
delete store.code['test_all.py'] | ||
continue | ||
} | ||
store.code[file] = renderCode(currentFiles[file], store.config) | ||
} | ||
} | ||
|
||
// ejs options | ||
ejs.localsName = 'it' | ||
ejs.delimiter = ':::' | ||
ejs.openDelimiter = '#' | ||
ejs.closeDelimiter = '#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.