Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The following code in fusion-acquia-slate-script.js adds a class to the first word of a block title, but it works only for English titles:
Drupal.behaviors.acquia_slateFirstWord = function (context) {
$('#site-name a').each(function(){
var bt = $(this);
bt.html( bt.text().replace(/(^\w+)/,'<span class="first-word">$1</span>') );
});
$('.title-dual h2.block-title').each(function(){
var bt = $(this);
bt.html( bt.text().replace(/(^\w+)/,'<span class="first-word">$1</span>') );
});
$('.title-white-bold-first h2.block-title').each(function(){
var bt = $(this);
bt.html( bt.text().replace(/(^\w+)/,'<span class="first-word">$1</span>') );
});
};
Recommend changing:
/(^\w+)/
to
/(^\S+)/
so that it works for other languages as well. Tested successfully locally.
Comments
Comment #1
TravisJohnston CreditAttribution: TravisJohnston commentedHello,
I was struggling with this for a while and I finally got it in a much simpler way. Create a block template, and look for the IF Subject area
if ($block->subject):
print $block->subject
endif;