I do this by passing blocks of template content via
layout variables. Thus you can put template specific content elements into a layout, but don't need to worry about doing any logic switching within the layout itself.
Here is an example:
First - here is the code within the layout to insert whatever is in a template design content block called
The logic tests to see if a layout variable has been set, and if it has been, simply includes it within the layout.
<!-- Specific Page Vendor and Views -->
<script src="/themes/site_themes/vendor/revolution/js/jquery.themepunch.tools.min.js" async></script>
When this page is rendered onscreen it gets the slider code added. When other templates use this layout they don't.
If you use nested layouts (a really good idea) you can extend this idea by simply 'passing' the template specific content down the layout chain using simple formats like this:
This structure simply looks to see if a layout variable of particular type has been set by a template, and if it has, passes it on to the next layout in the chain by setting a new layout variable with the same name.
Hope this makes sense... if not do clarify your question.