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

Cicero-core: Provide custom loadfilecontents and loadfilebuffer options in Template.fromDirectory() #745

Open
Ayman161803 opened this issue Aug 8, 2022 · 2 comments

Comments

@Ayman161803
Copy link

Feature Request 🛍️

Provide custom loadfilecontents and loadfilebuffer options in Template.fromDirectory()

Use Case

Loading template directories from a virtual file system where fs module cannot be used.
Example: VSCode-Web

Possible Solution

The options dictionary can accept option parameter loadFileContents and loadFileBuffer to alter the way in which file content is read from memory.

Context

A simple fix to this can be help us load Templates in VSCode Extension where only file reading logic is to be altered without altering the way in which the contents of these files are used to create the Template object.

Would you like to work on this?

Yes

@mehmettokgoz
Copy link
Contributor

Hi @Ayman161803, can you elaborate on this issue a little more?

  • What do you mean by loadFileContents and loadFileBuffer options? Which setting will they configure?
  • Is the problem with VSCode Extension you mentioned solved?

@Ayman161803
Copy link
Author

Hey @mehmettokgoz!

Apologies for the lack of clarity.

Some context

Currently, the logic written for loading templates from a VSCode workspace here and the logic written here is the same. The only difference is the way in which they load file contents. Where cicero-core uses fs, VSCode extension uses vscode.workspace.fs. Sometime in the future, if the logic to load templates from directories changes in cicero-core here, the same should be reflected in the logic written within VSCode extension code here.

Possible solution to prevent duplicate logic

  1. Allow the passing an optional loadFileBuffer and loadFileContents parameter into fromDirectory method here which will let us use the same fromDirectory method from cicero-core but with different logic to read and write files.
  2. Another way would be to mention the same in the comments above fromDirectory method in cicero-core that the logic is duplicated here. So that whenever something changes in cicero-core, the same is reflected in the code for vscode-extension.

I am not sure if the same can be achieved with the current core library itself. It would be great if you have any inputs @mttrbrts.

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

2 participants