yes,
you need to use below js to get runmode:
Read AEM runmodes from Sightly · GitHub (here you can find it in detail)
Lets say it runmode.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();
while (iterator.hasNext()) {
runmodesObj[iterator.next()] = true;
}
return {
runmodes: runmodesObj
}
});
HTL part
<sly data-sly-use.logic="runmode.js">
<p>Current runmodes: ${logic.runmodes}</p>// it will gives you all runmodes like
Current runmodes: crx3,author,samplecontent,crx3tar
<sly data-sly-test="${logic.runmodes.author}">
in author
</sly>
<sly data-sly-test="${logic.runmodes.publish}">
in publish
</sly>