Comments (2)
@danjor thanks for your support and active participation!
This sounds like an annoying problem.
Sorry,
Handling it on SCuri's side would be much more difficult (update templates are executed in isolation from each other and the main template).
from scuri.
Hello,
Thanks for your reply.
I'm giving you another example with more details to try to be more precise :
I have the following in my custom template
let <%= camelize(className) %>: <%= className %>;
<%params.sort((a,b) => a.type > b.type ? 1 : -1).forEach(p => {%>let <%= camelize(p.type.replace(new RegExp('\\[\\]', 'g'), 'List')) %>Spy: Spy<<%= p.type %>>;<% }) %> // this is for create
// scuri:lets // this is for update
// Below the template definition for lets update
/** scuri:template:lets:<%params.sort((a,b) => a.type > b.type ? 1 : -1).forEach(p => {%>let <%= camelize(p.type.replace(new RegExp('\\[\\]', 'g'), 'List')) %>Spy: Spy<<%= p.type %>>;
<% }) %>*/
and I also have custom helper function defined in the custom template :
<%
sortAsc = function(params) {
return params.sort((a,b) => a.type > b.type ? 1 : -1)
}
getLetVarname = (pType) {
return camelize(replaceArrayWithList(pType))
}
replaceArrayWithList = function(pType) {
return pType.replace(new RegExp('\\[\\]', 'g'), 'List')
}
%>
So I now want to use these functions in both directly from the custom template for the create (which already work), but also from all the scuri:template:* (does not work) :
let <%= camelize(className) %>: <%= className %>;
<%sortAsc(params).forEach(p => {%>let <%= getLetVarname(p.type) %>Spy: Spy<<%= p.type %>>;<% }) %> // this is for create
// scuri:lets // this is for update
// Below the template definition for lets update
/** scuri:template:lets:<%sortAsc(params).forEach(p => {%>let <%= getLetVarname(p.type) %>Spy: Spy<<%= p.type %>>;
<% }) %>*/
One way to acheive this could be to give the schematic the ability for user to provide not only the custom template, but also another custom template dedicated to helpers functions. This one could be provided in both from a new argument of the schematic or in the config file.
For this to work, you would need to provide all ejs with the template helper that contains custom functions, if that is possible ?
This way, all these function would be accessible from anywhere.
from scuri.
Related Issues (20)
- Delete the whole expression when removing dependencies HOT 1
- Add default Observable (EMPTY) and default Promise (new Promise()) values for dependency method spy return values.
- Lint on commit
- Handle properties with Promise or Observable HOT 1
- Handle update with a custom template without any custom functions
- Check for import of autoSpy when using --update on previously created spec file HOT 3
- Support inject function from angular
- Ensure jest specific mock returns are used
- Handle Arrays of deps
- Fix autoSpy import being added in the middle of other imports
- Fix adding multiple new lines when creating deps in setup method
- Combine TS Host with Tree
- Use FileVisitorCancelToken to stop after detected one or the other HOT 1
- Handle functions declared as const
- Allow for turning off the Typescript compilation dependent features as they take 5x or 10x more time
- Simplify the Observable property
- Update Scuri to support Typescript 5.0 and above HOT 1
- Don't update names of existing dependencies
- Mocking observable properties
- Handle Abstract class being dependend on
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scuri.