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

TravisJohnston’s picture

Hello,

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):

	
	$arr = explode(' ', trim($block->subject));
	$firstword = $arr[0];
	
	$block->subject = str_replace($firstword, '<span class="first-word">'. $firstword .'</span>', $block->subject); 

print $block->subject

endif;