Hi,
To manage/configure run mode specific value, you should use run mode osgi configuration and read key value using model.and store either in HTML hidden element or JSON object or use it if applicable. It will remove the extra run mode check overhead.
But if you want to check run mode, you have to go with server side JS Api or Java.
e.g.
template.html
<div data-sly-use.head="logic.js">
<p><b>Modes :</b> ${head.runmodes}</p>
<p><b>Is This author :</b> ${head.author}</p>
<p><b>Is This Publish :</b> ${head.publish}</p>
</div>
logic.js
var SlingSettingsService = Packages.org.apache.sling.settings.SlingSettingsService;
use(function () {
// Get runmodes and transform them into an object that is easier to read for Sightly
var runmodesObj = {};
var runmodesSet = sling.getService(SlingSettingsService).getRunModes();
var iterator = runmodesSet.iterator();
var isauthor=sling.getService(SlingSettingsService).getRunModes().contains("author");
var ispublish=sling.getService(SlingSettingsService).getRunModes().contains("publish");
while (iterator.hasNext()) {
runmodesObj[iterator.next()] = true;
}
return {
runmodes: runmodesObj,
author: isauthor,
publish: ispublish
}
});