Summary: | Kdevelop Snippets ${date} etc are ignored | ||
---|---|---|---|
Product: | [Developer tools] kdevplatform | Reporter: | Georg Michael Steyer <info> |
Component: | templates | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED NOT A BUG | ||
Severity: | normal | CC: | igorkuo |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Georg Michael Steyer
2023-03-04 12:53:38 UTC
Maybe this date feature simply doesn't exist? I don't see anything date-related in the relevant code: https://invent.kde.org/kdevelop/kdevelop/-/blob/master/plugins/appwizard/appwizardplugin.cpp#L255 You can implement the feature yourself if you need it badly enough. There *is* <year>, <month> and <day> support, but only in file templates, not app templates: https://invent.kde.org/kdevelop/kdevelop/-/blob/333b00441f10b8c4f8af35405d20338356fb14a9/plugins/filetemplates/licensepage.cpp#L242 Here is reformatted Milian's reply to the duplicate kdevelop-devel mailing list question: That area is also a bit messy in KDevelop, and not something I use frequently myself. First of all, can you please be more specific what kind of template/ snippet you are using? We sadly have basically three different systems in place: - new file template (#1) - new project template (#2) - text snippets to insert an open document (#3) > * Copyright %{year} Milian Wolff <mail@milianw.de> I assume here you are talking about the "snippets" plugin (#3), there the syntax would be: ${year()} And you'll have to provide a javascript function like this in the `scripts` tab: function year() { return new Date().getFullYear(); } > My own template should look like /usr/share/kdevcodegen/licenses/GPL v3: > Copyright (C) <year> <copyright holder> > But also here "<day>.<month>.<year>" are not expanded to the current date. For project templates (#2), we rely on grantlee which is similar to django in spirit. There, the syntax would be something like {% now "yyyy" %} if I'm not mistaken. The `<year>` token is only replaced for file templates (#1). |