Entry tags:
Constants Namespaces in .tt files
I'm looking for feedback on Bug 3170: Constant Namespaces in DW::Template.
Basically, right now our constants in .tt files can be found under email.*, site.*, roots.*, etc, and the more constants we have, the more likely it is that we'll accidentally have a namespace collision. So I would like to have all constants be under just the site namespace.
That is, instead of using:
email.webmaster
roots.site
site.name
We can use:
site.email.webmaster
site.root
site.name
In some cases, it's longer, but the additional clarity should be worth the extra characters. (Plus it would also make it easier to avoid mistakes -- I found several instances of dw.* in the files, which are blank, but luckily cause no issues)
site.name = $LJ::SITENAME
site.names.short = $LJ::SITENAMESHORT
site.names.abbrev = $LJ::SITENAMEABBREV
site.company = $LJ::SITECOMPANY
site.email.coppa = $LJ::COPPA_EMAIL
site.email.privacy = $LJ::PRIVACY_EMAIL
site.domain = $LJ::DOMAIN
site.domains.web = $LJ::DOMAIN_WEB
site.root = $LJ::SITEROOT
site.roots.img = $LJ::IMGPREFIX
site.roots.ssl = $LJ::SSLROOT
site.help.* = \%LJ::HELPURL
I'd like to point out, in particular,
site.name = $LJ::SITENAME
site.names.short = $LJ::SITENAMESHORT
site.names.abbrev = $LJ::SITENAMEABBREV
which suffers from inconsistency/needing to be aware of the technical limitations.
An alternative:
site.name.site = $LJ::SITENAME
site.name.short = $LJ::SITENAMESHORT
site.name.abbrev = $LJ::SITENAMEABBREV
But that suffers from the problem that the most commonly used variable, site.name, becomes long/ridiculous/redundant.
Basically, right now our constants in .tt files can be found under email.*, site.*, roots.*, etc, and the more constants we have, the more likely it is that we'll accidentally have a namespace collision. So I would like to have all constants be under just the site namespace.
That is, instead of using:
email.webmaster
roots.site
site.name
We can use:
site.email.webmaster
site.root
site.name
In some cases, it's longer, but the additional clarity should be worth the extra characters. (Plus it would also make it easier to avoid mistakes -- I found several instances of dw.* in the files, which are blank, but luckily cause no issues)
site.name = $LJ::SITENAME
site.names.short = $LJ::SITENAMESHORT
site.names.abbrev = $LJ::SITENAMEABBREV
site.company = $LJ::SITECOMPANY
site.email.coppa = $LJ::COPPA_EMAIL
site.email.privacy = $LJ::PRIVACY_EMAIL
site.domain = $LJ::DOMAIN
site.domains.web = $LJ::DOMAIN_WEB
site.root = $LJ::SITEROOT
site.roots.img = $LJ::IMGPREFIX
site.roots.ssl = $LJ::SSLROOT
site.help.* = \%LJ::HELPURL
I'd like to point out, in particular,
site.name = $LJ::SITENAME
site.names.short = $LJ::SITENAMESHORT
site.names.abbrev = $LJ::SITENAMEABBREV
which suffers from inconsistency/needing to be aware of the technical limitations.
An alternative:
site.name.site = $LJ::SITENAME
site.name.short = $LJ::SITENAMESHORT
site.name.abbrev = $LJ::SITENAMEABBREV
But that suffers from the problem that the most commonly used variable, site.name, becomes long/ridiculous/redundant.
no subject
site.name
site.nameshort
site.nameabbrev?
no subject
site.name
site.name.short
site.name.abbrev?
no subject
$site{name} = "value";
$site{name} = {};
$site{name}->{short} = "value";
That is, the value is overwritten.
There may be a way around it, but if there is, I haven't found it yet.
no subject
no subject
I will probably go with the simpler solution that kareila suggested o/
no subject
In specific, I think Jen's suggestion is great.