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

Add resources.Put(targetPath) #7406

Closed
bep opened this issue Jun 18, 2020 · 5 comments
Closed

Add resources.Put(targetPath) #7406

bep opened this issue Jun 18, 2020 · 5 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Jun 18, 2020

See discussion in: https://discourse.gohugo.io/t/babel-ts-file-extension-remains-ts/26318/6

I answered a little hasty in that thread, as I had forgot my own API in this area. For ToCSS we have a TargetPath option, for babel and postCSS we have not (mostly because, I think, I assumed you would want the same path as the input).

Instead of adding TargetPath to every transformer function that could potentially need it, I suggest we add a resources.Copy function that takes the targetPath as the only argument. So you could do:

{{ $myTypeScript := resources.Get "myjs.js" | babel | resources.Copy "mytypescript.ts" }}

Note that a current workaround for the above would be:

{{ $js := resources.Get "myjs.js" | babel  }}
{{ $ts := slice $js | resources.Concat "mytypescript.ts" }}

@regisphilibert -- the master of naming things, do you think the above is a good idea and that the function name is good?

@bep bep added this to the v0.73 milestone Jun 18, 2020
@bep bep added the Proposal label Jun 18, 2020
@regisphilibert
Copy link
Member

regisphilibert commented Jun 18, 2020

This is a great idea. Now when I read Copy I'm tempted to think I'll end up with duplicates and maybe others will.

Unless it's programatically crazy to use put as a method name, I think .Put would be a good counter to .Get and give a sense that this will define "where" the file will live (will be put) when published.

Also, whenever dealing with temporary files (php upload etc...), people are used to move. But again, it's still pointing to an action which is not really happening... nothing really gets moved...

@bep
Copy link
Member Author

bep commented Jun 18, 2020

Now when I read Copy I'm tempted to think I'll end up with duplicates and maybe others will.

You kind of do if you construct it like this:

{{ $js := resources.Get "myjs.js" | babel  }}
{{ $ts := $js | resources.Copy "mytypescript.ts" }}

I kind of like .Put, too, but let it linger.

@bep
Copy link
Member Author

bep commented Jun 18, 2020

Given the discussion above, what would be the best name for this new function:


@bep bep changed the title Add resources.Copy(targetPath) Add resources.Put(targetPath) Jun 19, 2020
@bep bep self-assigned this Jun 19, 2020
@bep bep removed the Proposal label Jun 19, 2020
@bep bep modified the milestones: v0.73, v0.74 Jun 23, 2020
@bep bep modified the milestones: v0.74, v0.75 Jul 13, 2020
@bep bep modified the milestones: v0.75, v0.76 Sep 14, 2020
@bep bep modified the milestones: v0.76, v0.77 Oct 6, 2020
@bep bep modified the milestones: v0.77, v0.78 Oct 30, 2020
@bep bep modified the milestones: v0.78, v0.83 Apr 23, 2021
@bep bep modified the milestones: v0.83, v0.84 May 3, 2021
@bep bep modified the milestones: v0.84, v0.85 Jun 18, 2021
@bep bep modified the milestones: v0.85, v0.86 Jul 5, 2021
@bep bep modified the milestones: v0.86, v0.87 Jul 26, 2021
@bep bep added this to the v0.101.0 milestone May 31, 2022
@bep bep modified the milestones: v0.101.0, v0.102.0 Jun 16, 2022
@bep bep modified the milestones: v0.102.0, v0.103.0 Aug 28, 2022
@bep bep modified the milestones: v0.103.0, v0.104.0 Sep 15, 2022
@bep bep modified the milestones: v0.104.0, v0.105.0 Sep 23, 2022
@bep bep modified the milestones: v0.105.0, v0.106.0 Oct 26, 2022
@bep bep modified the milestones: v0.106.0, v0.107.0 Nov 18, 2022
@bep bep modified the milestones: v0.107.0, v0.108.0 Dec 3, 2022
@bep bep modified the milestones: v0.108.0, v0.109.0 Dec 14, 2022
@bep bep modified the milestones: v0.109.0, v0.111.0, v0.110.0 Jan 26, 2023
@bep bep modified the milestones: v0.111.0, v0.112.0 Feb 15, 2023
@jmooring
Copy link
Member

jmooring commented Apr 8, 2023

Addressed by #9920

@jmooring jmooring closed this as completed Apr 8, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants